Skip to content

fix(web): resume the gallery's wasm download after an interruption - #2644

Merged
oneo-me merged 2 commits into
nsgo-dev:mainfrom
Laotree:feature/resume-gallery-download
Nov 29, 2026
Merged

oneo-me merged 2 commits into
nsgo-dev:mainfrom
Laotree:feature/resume-gallery-download

Conversation

@Laotree

@Laotree Laotree commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Switching tabs, reloading the page or changing the platform in the gallery dropped the 15 MB wasm download and started it again. The loader now keeps each batch in IndexedDB and continues a stored prefix with a Range request; every answer is checked against Content-Range before the bytes are joined. The shell's 45 s watchdog is a stall timer now: progress resets it, and time spent hidden does not count.

Fixes #2590.

Targets

  • Docs or website only

Screenshots

None: the boot screen keeps its layout. While the page is hidden it shows "Paused. The download continues when you return."

Verification

  • head: a84474d28802ae29d121f1b8349feb48e7dd1def
  • base: f01acedfbfd98b4cb747c753fb99aaa34675f90e
  • commands:
    • cd website && bun test → 0
    • cd website && bun run build → 0
    • cd website && bun scripts/test-gallery-resume.mjs → 0
    • go run ./tools/changelog check → 0
    • go tool nsgo check -target web -jobs 4 → 0
  • result: pass
  • not covered: go tool nsgo test (website-only change; the full suite runs over an hour on this machine), the Android emulator, Windows, Linux and the browser jobs, and tab switching in Safari on an iPhone

Rebased onto main after #2650 (zstd): the loader now hands the resumed bytes to the zstd decoder. A follow-up commit takes a body the host already decoded (Content-Encoding set, more bytes than Content-Length) as it comes, without storing it, as main's loader did, instead of restarting five times and failing; a test covers it. test-gallery-resume.mjs reads config.stream.

The author's earlier runs, on 1bf78ce29:

  • cd website && bun test scripts/gallery-download.test.js — 11 pass, 0 fail. Covers the resumed Range and If-Range headers, a 200 that ignores the range, a mismatched Content-Range, a 416, a missing store, offset-order joining, cleanup after success, pause while hidden, and a stored total that differs from the build size.
  • cd website && bun run build — exit 0 (gallery, astro check and the site build).
  • cd website && bun scripts/test-gallery-resume.mjs — PASS. A plain load downloads once; a dropped response then a reload asks for bytes=262144- and reaches ready; IndexedDB holds no entries afterwards.
  • go run ./tools/changelog check — 62 fragments, exit 0.
  • go tool nsgo check — exit 0.
  • go tool nsgo test — 5220 pass, 2 fail on this branch. Both fail on this machine only:
    • TestMaxRefreshRateReadsEveryMode: the display reports 0 Hz for its modes. macOS CI passes; a separate test-only pull request fixes the check.
    • TestWebViewUnderOverlayIgnoresHoverAndCursor: fails identically on the untouched base 6416e1a0b (unexpected page pointer event).
      A first run overlapped a local site build and timed out three GUI/SDK tests at the package level; the numbers above come from the clean rerun.
  • Server premise: curl -r 0-1023 https://nsgo.dev/gallery/apps/app.2e60603ee6.wasm.gzip answers 206.

website.yml builds only on pushes to main, so this pull request gets no website CI. The build and the browser test ran locally on this branch.

Checklist

  • The title is a Conventional Commit, such as fix(web): resume the gallery's wasm download after an interruption; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

🤖 Generated with Claude Code

@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation website labels Nov 27, 2026
@Laotree Laotree closed this Nov 27, 2026
@Laotree Laotree reopened this Nov 27, 2026
@Laotree
Laotree force-pushed the feature/resume-gallery-download branch from bb305ef to 7589fee Compare November 27, 2026 11:20
@Laotree
Laotree force-pushed the feature/resume-gallery-download branch 2 times, most recently from 5b6a557 to 1bf78ce Compare November 27, 2026 12:02
@Laotree

Laotree commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Note for whoever lands this: #2650 changes gallery-loader.html, build-gallery.mjs and website/package.json too. A trial merge of the two heads conflicts in all three, so whichever lands second needs a rebase.

Laotree and others added 2 commits November 29, 2026 20:43
A tab switch, a reload or a platform change dropped the downloaded
bytes, so the 15 MB wasm started again. Keep each batch in IndexedDB,
continue a stored prefix with a Range request, and check every answer
against Content-Range before joining bytes. The shell's stall timer no
longer counts the time a hidden page spends away.

Refs nsgo-dev#2590

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oneo-me
oneo-me force-pushed the feature/resume-gallery-download branch from 724f9b6 to a84474d Compare November 29, 2026 12:43
@github-actions github-actions Bot added local-ci-pass The head commit declares that its local checks passed and removed local-ci-skipped labels Nov 29, 2026
@oneo-me
oneo-me enabled auto-merge (rebase) November 29, 2026 12:54
@oneo-me
oneo-me merged commit e4cd4e3 into nsgo-dev:main Nov 29, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation local-ci-pass The head commit declares that its local checks passed size/XL website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): resume the gallery's wasm download instead of restarting it

2 participants