Skip to content

Web: report engine boot phase before callMain blocks the main thread - #6

Open
octopusburrow wants to merge 3 commits into
dwalter:webgpu-4.6.2from
octopusburrow:pr4-informative-loader
Open

Web: report engine boot phase before callMain blocks the main thread#6
octopusburrow wants to merge 3 commits into
dwalter:webgpu-4.6.2from
octopusburrow:pr4-informative-loader

Conversation

@octopusburrow

Copy link
Copy Markdown

After the download completes, the loading bar sits at 100% while callMain runs the
engine's synchronous start-up (module/physics init; on WebGPU, shader/pipeline
compilation) — several seconds of apparent freeze, sometimes long enough for Chrome's
"Page Unresponsive" while the page is still in fact loading correctly. This adds an
opt-in onStatusChange config callback fired with a machine-readable boot-phase token
('shader-compile' when a pre-initialized WebGPU device will compile pipelines,
'engine-init' otherwise; the shell owns the display text), plus a paint yield before
the blocking call: one rAF to reach a frame boundary, then ~100ms for the compositor to
present, with an absolute run-once fallback for backgrounded tabs where rAF is
suspended. A double rAF is not sufficient — measured by compositor capture, under
post-download load both callbacks fire back-to-back with no frame between them. The
yield also gives the event loop a task boundary, resetting Chrome's responsiveness
watchdog, so one repaint informs the user and defers the "Page Unresponsive" prompt;
heavier chunked-yield schemes aren't warranted for a one-time boot cost. The phase line
is positioned like the progress bar, since the absolutely-positioned splash paints over
normal-flow content. Both bundled shells are wired up; the WebGPU shell also corrects
renderingDriver in its config when falling back to GL, so the reported phase matches
the driver that actually runs.

No change when the callback isn't set. The freeze duration is unchanged — this makes it
legible, not shorter. Verified with compositor-side captures: the phase message is on
screen for the whole blocking span.

After the download completes the loading bar sits at 100% while callMain
runs the engine's synchronous start-up (module/physics init and, on
WebGPU, shader/pipeline compilation). The page looks frozen and Chrome
raises 'Page Unresponsive'. Add an opt-in onStatusChange config callback,
fired with a boot-phase message and given a paint yield (double rAF)
before the blocking call, and wire it into both bundled HTML shells.
…blocks

The double-rAF yield was measured (CDP screencast, two runs) failing under
post-download main-thread load: both rAF callbacks fired 2-8ms apart with no
compositor frame between them, so the phase message never reached the screen
once. Align to a frame boundary with a single rAF, then allow the compositor
100ms to present the committed change; keep an absolute 1s fallback for
background tabs where rAF is suspended.
The splash is absolutely positioned, and positioned elements paint above
normal-flow content regardless of DOM order — so the phase line rendered
underneath the opaque splash (measured: elementFromPoint at the text's
center hit #status-splash; compositor frames pixel-identical across the
text mutation). Position it like the progress bar, just beneath it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant