Repository navigation
fix: a first play without Range boots in the package's language, and two worker states are read right - #59
Merged
Conversation
…two worker states are read right - On a host without Range the worker opens its reader at the first progress report. When h5p.json was not among the first bytes, a later snapshot brought it in and nothing saved it to the record, which the frame route reads: the frame booted early in the element's language, untitled and unlicensed, until a reload. refresh() saves it now. - stillRegistered took any live registration at the scope for the element's own. After site data was cleared and another player or tab registered first, the element kept posting to a registration with no worker, and every load failed with no-worker until a reload. - In a frame sandboxed without allow-same-origin, reading navigator.serviceWorker throws in Chromium and WebKit. The element read it in connectedCallback and stopped before its load began, with no error event; it reports no-worker now. Also corrects three runtime comments that still said the core's strings follow the element's language. Closes #57. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57.
Three defects in the player, found reviewing the changes of 2026-10-18 to 20. Each fix comes with a test that fails without it.
Changes
1. The manifest reaches the record when it arrives late (
sw/mount.ts)Range, the worker opens its reader at the first progress report. Whenh5p.jsonwas not in the first 256 kB, a later snapshot brought it in andrefresh()saved nothing. The frame route reads the title, metadata and (since H5P's own strings follow the content's language #55) the language off the record. So the frame booted early in the element's language, untitled and with no licence, until a reload.refresh()saves the manifest to the record when a merged snapshot bringsh5p.jsonin.2. The registration found must be the element's own (
h5p-offline-player.ts)stillRegisteredaccepted any live registration at the scope. After site data was cleared and another player or tab registered first, the element kept its old registration, which has no worker once its last client is gone. Every load then failed withno-workeruntil a reload.current === registration. If an engine ever handed out a new object for the same registration, the element would only register again on each load, which is harmless.3. A sandboxed frame reports
no-worker(h5p-offline-player.ts,docs/troubleshooting.md)allow-same-origin,'serviceWorker' in navigatoris true and reading the property throws aSecurityErrorin Chromium and WebKit. Checked in Playwright's three engines; Firefox returns the container.connectedCallbackread it (?.doesn't catch a throw), so the element stopped before its load began and fired noerror. The embed page then never showed its "open in its own tab" link.serviceWorkers(), reads the container and treats a throw as none. The element reads the property only through it. The load fails withno-worker, and the message names the sandbox. The troubleshooting table lists it.Also
Testing
New tests, each run with and without its fix:
l10n.test.ts:german-late-manifest.h5p(new fixture:h5p.jsonbehind 1 MB of media, 4 MB more after it), played without Range at 1 MB/s on an English page. It asserts the frame booted before the download finished, thenlang="de", "Vollbild", the frame's title and the licence.expected 'en' to be 'de'recovery.test.ts: a player's frame is emptied and its registration unregistered; a second player registers again; the first plays again.errors.test.ts:navigator.serviceWorkermade to throw as in a sandboxed frame.networkinstead ofno-worker, plus two uncaughtSecurityErrors fromconnectedCallbackThe second test empties the frame before unregistering. Unregistered while a frame was still its client, the registration was brought back by Chromium for the next
register, which never reaches the bug.Suites:
pnpm typecheckpasses for the player and the runtime.findMountedRoutesand the identity check now apply.A flaky test to know about:
worker-update.test.ts› "waits for the update however slow the script…" failed in 2 of 15 full Chromium runs on this branch, ending in under 4 s. On main it passed 3 of 3. On this branch it passes alone (4 of 4) and paired with each changed file (3 of 3 each). The path it exercises, a new element per test, does nothing different here. It has not failed in CI's last ten failed runs. My guess, unconfirmed: under a busier suite, the previous test's soft update is still running wheninstallVersioncallsupdate(), and that call joins it instead of installing 0.99.0. If CI hits it, re-run; hardeninginstallVersionwould be its own change.Not verified:
unregister()with no clients.boardgame.h5pitself. The fixture reproduces its layout.Release
A player patch (1.1.1). The runtime changes are comments only.
🤖 Generated with Claude Code