fix(viewer): drive the frame loop with a timer when ?disable=draw#483
Merged
Conversation
With no real frames submitted, Chromium's no-damage scheduler throttles requestAnimationFrame to 1Hz on Linux — measured in the headless bake worker: every useFrame system ticked once per second, so a heavy scene needed 300+ seconds of wall time just to run ~300 frames of build work (and exceeded the capture deadline on the worker's slower cores). The empty-scene clear from #482 avoids this on macOS but not on Linux. When `draw` is disabled, drive advance() with setInterval instead of rAF — plain timers are never throttled on a visible page, so the loop pacing is deterministic (fps prop) regardless of compositor heuristics. Normal rendering paths are untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4 tasks
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.
What does this PR do?
Follow-up to #482. On Linux (the headless bake worker), Chromium's no-damage scheduler throttles
requestAnimationFrameto 1Hz when the page never submits a real frame — measured in the prod-image container: main thread fully idle, rAF gaps exactly 1017ms, so everyuseFramesystem ticked once per second and a heavy scene needed 300+ seconds just to execute its ~300 frames of build work (and blew the capture deadline on the worker's slower cores). The #482 empty-scene clear prevents this on macOS but not on Linux.Fix: when
?disable=drawis active,FrameLimiterdrivesadvance()fromsetIntervalinstead of rAF. Foreground-page timers are never throttled, so loop pacing is deterministic (thefpsprop) regardless of compositor heuristics. The normal rendering path is unchanged (still rAF).How to test
bun dev, open/bake/demo_office?disable=postFx,draw—window.__BAKE__resolves in seconds (validated: 8.9s for a 200+-item scene, output in the normal byte range).draw— unchanged (verified demo_1 normal render byte-equal).project_2VqMH2p0YduKVd3i) should complete a headless CPU-only bake for the first time.Screenshots / screen recording
N/A — headless-only behavior.
Checklist
bun devbun checkto verify)mainbranch🤖 Generated with Claude Code
Note
Low Risk
Scoped to the ?disable=draw code path; normal viewer rendering still uses rAF unchanged.
Overview
When
?disable=drawis set (headless bakes that skip real drawing),FrameLimiternow advances the R3F loop withsetIntervalat the configuredfpsinstead ofrequestAnimationFrame.On Linux, Chromium throttles rAF to ~1Hz when no real frames are submitted, which made
useFramesystems crawl during bakes. Timers stay at full rate on a visible page, so build work can finish in seconds without changing the normal rAF path when drawing is enabled.Cleanup cancels the interval on unmount alongside the existing rAF teardown.
Reviewed by Cursor Bugbot for commit 892eb62. Bugbot is set up for automated code reviews on this repo. Configure here.