fix(engine): apply compositor determinism flags in screenshot mode#865
Closed
miguel-heygen wants to merge 1 commit into
Closed
fix(engine): apply compositor determinism flags in screenshot mode#865miguel-heygen wants to merge 1 commit into
miguel-heygen wants to merge 1 commit into
Conversation
Chrome's compositor determinism flags (--run-all-compositor-stages-before-draw, --disable-threaded-animation, --enable-surface-synchronization, etc.) were previously only applied for BeginFrame mode on Linux. In screenshot mode — used on macOS/Windows — the compositor ran without these constraints, allowing Metal on Apple Silicon to accumulate state drift over sustained frame captures. This produced vertical layout shifts after ~12 seconds of rendering, reported on M1 machines. The shifts occurred because the compositor's threaded animation and surface synchronization pipelines could race with Page.captureScreenshot, and without --run-all-compositor-stages-before-draw, pending compositor stages weren't flushed before each screenshot. Split the flags into two groups: - BEGINFRAME_EXCLUSIVE_FLAGS: --enable-begin-frame-control and --deterministic-mode, which pause the compositor or freeze the clock and must NOT be used in screenshot mode - COMPOSITOR_DETERMINISM_FLAGS: the remaining 7 flags that enforce deterministic compositor behavior and are safe for all capture modes The compositor flags are now applied unconditionally in buildChromeArgs. Closes #828
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.
Summary
--run-all-compositor-stages-before-draw,--disable-threaded-animation,--enable-surface-synchronization, etc.) were only applied for BeginFrame mode (Linux). Screenshot mode (macOS/Windows) ran without them, allowing Metal's compositor to accumulate state drift over sustained frame captures--enable-begin-frame-control,--deterministic-mode) and 7 compositor-determinism flags that are safe for all modes. The 7 are now applied unconditionallyDetails
The compositor determinism flags enforce:
--run-all-compositor-stages-before-draw— flush all compositor stages before each draw/screenshot--disable-threaded-animation— animations process on main thread, not a separate compositor thread--enable-surface-synchronization— renderer and browser compositor surfaces stay in sync--disable-threaded-scrolling,--disable-checker-imaging,--disable-image-animation-resync,--disable-new-content-rendering-timeout— remove other sources of non-determinismWithout these, Chrome's Metal backend (Apple Silicon) could race between the compositor thread and
Page.captureScreenshot, accumulating vertical offset over hundreds of frames.Test plan
Closes #828