fix(viewer): kick render on focus and visibility resume#439
Open
Aymericr wants to merge 1 commit into
Open
Conversation
With frameloop="never" the rAF loop is the only render driver. Browsers throttle requestAnimationFrame when the tab is hidden/unfocused/occluded, which freezes the canvas (the viewer appears to 'turn off' between interactions on Linux Firefox/Chrome/Zen). Add visibilitychange/focus/pageshow listeners that force one synchronous advance() on resume, with matching cleanup. Lands #291 (mvanhorn) onto current main (resolves the comment-context conflict). Fixes #275. Closes #196. Co-authored-by: mvanhorn <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
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.
Lands #291 (@mvanhorn) onto current
main. The original PR was correct but conflicted on surrounding comments; this is the same fix rebased clean.With
frameloop="never"the rAF loop is the only render driver. Browsers throttlerequestAnimationFramewhen the tab is hidden/unfocused/occluded, freezing the canvas (viewer appears to 'turn off' between interactions). Addsvisibilitychange/focus/pageshowlisteners that force one synchronousadvance()on resume, with matching cleanup. Deps unchanged.Typecheck + lint pass. Co-authored with @mvanhorn. Fixes #275, closes #196.
Note
Low Risk
Small, localized viewer render-loop change with proper listener cleanup; no auth, data, or API surface changes.
Overview
Fixes a frozen canvas when the tab is hidden, unfocused, or occluded while
FrameLimiterruns withframeloop="never"(rAF is the only render driver).Adds a
kick()helper that bumps the internal clock and callsadvance()once synchronously.visibilitychange(when state becomes visible),windowfocus, andpageshowinvoke it so the first frame after resume reflects current scene state. The effect cleanup removes those listeners alongside the existing rAF cancel and frameloop restore.Reviewed by Cursor Bugbot for commit 7dada9c. Bugbot is set up for automated code reviews on this repo. Configure here.