Repository navigation
fix(chromium): let attached pages install service workers - #293
Merged
Merged
Conversation
chromiumoxide 0.9.1 auto-attaches to every page with waitForDebuggerOnStart: true. A service worker registered under it starts paused, and chromiumoxide resumes and detaches it in the same breath. When the worker's main script is still loading at that moment, the resume is lost with the session: the worker stays paused-on-start, and the page's navigator.serviceWorker.register() never settles. Majsoul's WebGL boot awaits that registration, so the game stays on a black screen or the logo whenever a new sw.js version has to install. Patch chromiumoxide to a fork that is 0.9.1 plus one commit that auto-attaches without pausing. Nothing is done while an auto-attached target is paused, so the pause has no use. The new browser test registers a worker whose script is served late, with the real CDP loop attached. It times out without the patch and passes with it.
Owner
Author
|
/build-artifacts |
|
✅ PR build completed Commit: Artifacts expire after 14 days. |
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.
Fixes #292.
Problem
With
[capture] mode = "chromium", Majsoul stays on a black screen or the logo whenever a newsw.jsversion has to install (game update, cleared site data, fresh profile). The page'snavigator.serviceWorker.register()never settles, and the WebGL boot awaits it, so the Unity build is never requested.Cause
chromiumoxide 0.9.1 auto-attaches to every page with
Target.setAutoAttach { waitForDebuggerOnStart: true }. A new service worker therefore starts paused. When chromiumoxide sees it attach, it sendsRuntime.runIfWaitingForDebuggerandTarget.detachFromTargetback to back, without waiting for the resume to land. If the worker's main script is still loading at that point, the resume is lost with the session. The worker stays in the paused-on-start state (status: new,runningStatus: starting), and every later registration job for that scope queues behind it. That is why a registration of a 404 script hangs too, instead of rejecting.A fast script response hides the race. In local tests it shows up once
sw.jstakes about 300 ms, which a CDN response easily does. Re-arming auto-attach without the pause from Akagi after attaching does not help: the game registers its worker while chromiumoxide is still initializing the page, before Akagi gets thePage.Fix
Patch chromiumoxide (
[patch.crates-io]) to shinkuan/chromiumoxide@17c2e5a. That is thev0.9.1tag plus one commit that auto-attaches withwaitForDebuggerOnStart: false. chromiumoxide does nothing while a target is paused and resumes each one right away, so the pause has no use. The patch can be dropped once a chromiumoxide release carries the fix.Cargo.lockchanges only the source of the four chromiumoxide crates.Tests
New
tests/chromium_service_worker.rs(ignored by default, needs a Chromium browser). It runs the realcdp::runloop against headless Chrome and opens a page that registers a service worker whose script is served 1.5 s late.register=timeout&ready=timeout.tests/chromium_telemetry_block.rs(ignored) still passes, including the dedicated-worker beacon.Real
game.maj-soul.comin headless Chrome 155, with a harness that uses chromiumoxide the same way:framework.jsframework.jsloadedcargo fmt --check,cargo clippy --all-targets -D warningsandcargo testpass.