Repository navigation
Conversation
- Reload once this script's own worker is active, not on updatefound or a stale active/controller check - Reload at most once per attempt (URL fragment marker); warn instead of looping when isolation is blocked - Warn instead of throwing when service workers are unavailable
This branch has not been deployed
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.
The web editor's bootstrap (
emscripten_enable_shared_array_buffer.js) registers a service worker that adds COOP/COEP headers, then reloads so the page is served cross-origin isolated (needed for SharedArrayBuffer/WASM threads). The page-side reload logic had several startup races and failure modes that leave the editor on a black canvas or reload it endlessly:updatefound, while the worker is only just installing, so the reloaded page often wasn't controlled yet and needed a second reload. If theregister()result arrived after the worker had already activated and claimed the page, it didn't reload at all.clients.claim()(F5 or a second tab during the first install) counted as controlled and was never reloaded, even though it hadn't been served with COOP/COEP.navigator.serviceWorkeris undefined.Changes (page side only; the worker is unchanged)
#coi-reloadedin the URL (stripped on the next load). If the page is still not isolated after that reload, log a warning that isolation is being blocked instead of reloading again. The marker lives in the URL because Chrome switches browsing context group when COOP starts or stops applying. Across that switch, asessionStorageflag can come back stale after a hard reload (the editor then gives up), andhistory.stateis dropped.Testing
Ran a local harness: the real
emscripten_shell.htmlwith a stub NodeEditor module, in fresh headless Chrome 155 and Firefox 157 profiles (3–10 runs per case).register()result delivered 300 ms latePermissions-Policy)Not covered: Safari, and the real WASM build (JS-only change, no native code touched).
Possibly related to the black screen reported in #185, but that report's cause isn't confirmed, so this doesn't claim to fix it.