fix(cef): a page's first paint settles the base on its own color; no white frame before a dark page
Summary
BROWSER VIDEO F4. In the 120 Hz films, the whole page area of a browser pane was white for 1-3 frames when I navigated to a dark page in the dark theme. It showed after the theme-colored loading ground and before the page's own first frame. This happened in 3 of 9 navigations (a race).
Cause: CEFFirstPaintBridge.painted settled the document at its first contentful paint. The page base then took the document's own color, pageBackdropARGB. That color is read only at load end (samplePageBackdrop on .loadEnd), so at first paint the base went to white. The paint signal comes before the painted frame is on screen, so the white base showed until that frame arrived.
Fix: the first paint, the load end and the load stop (.loadingState(false)) all go through documentDidPaint:
- One background read per document (
pageBackdropScript), so the base settles on the page's own color. It is white only for a page with no background. - The wait is bounded at 100 ms (
settleReadLimit, aDemandTimer). After the wait, the document settles as before, and a late answer still applies. - A load end or stop during the read owes one more read after its answer.
- A load end on a settled document reads the color again, as load end always did.
- A failed read, or the
pageBackdroptunable off, settles at once, as before.
On "switch on the first presented frame": the fork API has no presentation or CA-commit signal for a page window, so that would need a fork change. This fix needs none, because the base only changes to a color the page itself has.
Changelog
Fixed: Opening a dark web page in a dark theme no longer flashes white for a moment before the page draws.
Evidence
- Red films (feat 0d19fe6 + recorder, build 35c4c3bd, cmux19/21, 120 Hz virtual display): white page area in 3 of 9 navigations. Stills: https://cmux-orchestrator-1.tail137216.ts.net/resize-videos/bv-findings/dark-pane-nav-white-f357.png (before:
-before-f355, after:-after-f359). - Green film (build 39a45f92: the same base plus this fix, branch
test/bv-f4-fix-film, cmux21, 05:19-05:27Z): 0 of 9 navigations show a white frame. - Regression test:
CEFFirstPaintBaseTests(red at ff1a2d942ab, green at the head). The fleet red/green is pending Mac-lane access for this branch.
Observed / Not run
- Observed:
- Red films: 3 of 9 navigations white.
- Green film (build 39a45f92, an earlier head with paint-only read-then-settle): 0 of 9.
- Compile v2 at 9b5c9408ecb: passed (CmuxNext 246 s, app 82 s, cmux-tui 11 s).
- Five independent review rounds; the last one is a SHIP at 9b5c9408ecb.
- Not run:
- The Swift red/green of
CEFFirstPaintBaseTests(9 tests). This branch is not yet on the Mac lane allow list.ready-to-landwaits for it. - The film of the final head (build b14ce711, an intermediate head, waits for a mini).
- The Swift red/green of
No capture: no new UI; the films are the before and after.