Closed
Conversation
Copilot stopped work on behalf of
velzie due to an error
June 20, 2026 17:15
codebutler
pushed a commit
to codebutler/firefox-wasm
that referenced
this pull request
Aug 11, 2026
An embedder had no way to know when pixels first reach the canvas. `load()` resolving means the DOCUMENT finished loading, and in GPU mode WebRender presents autonomously off the refresh driver — so a window sits blank for as long as RenderThread's device init takes (3.1–4.5s measured under software GL) with nothing to wait on. That reads as a broken embed, and the only workaround available downstream was a settle timer, i.e. a guess. gl_present_yield is the one place that observes the present: the browser implicit-presents during the macrotask it yields for, so by the time its setTimeout callback runs, that frame is up. It now reports each present to the main thread via emscripten's CMD_CALL_HANDLER (whose dispatch is per-instance-correct, so two embedded instances on a page don't cross wires), and Gecko exposes `firstPaint`. Picking WHICH present means "there is content" took three traces, and both obvious rules are wrong: A: present HeyPuter#1 t=27.6s, load stop t=27.8s, present HeyPuter#2 t=29.3s B: load stop t=24.2s, present HeyPuter#1 t=27.5s, present HeyPuter#2 t=29.8s C: load stop t=50.8s, present HeyPuter#1 t=55.3s, present HeyPuter#2 t=58.1s "First present" is blank in A. "First present after the load settles" is blank in B and C, where that present IS HeyPuter#1. The invariant across all three is that the compositor's opening present is a device-init frame carrying no content, so firstPaint requires BOTH: the load has settled AND the present index is >= 2. The >= 2 is empirical, not derived — Gecko exposes no first-contentful-paint to an embedder — and it is commented as such rather than dressed up. Reporting stops after PRESENT_REPORT_CAP presents so a long-running engine isn't posting a message per frame forever; reaching the cap resolves firstPaint anyway, so a pathological first load degrades to "uncover" instead of wedging an embedder that awaits it. GECKO_PRESENT_DEBUG logs the trace that produced the table above. Software mode never presents this way and resolves once the engine is up. Co-Authored-By: Claude Opus 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.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.