Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewer suspend rendering when not visible #15835

Merged

Conversation

ryantrem
Copy link
Member

This change makes is so that when the viewer element is not within the browser viewport, it suspends the render loop (to avoid unnecessary power consumption, and also to help scale if you have a page with many viewer instances).

  • Introduce a suspendRendering function on the lower level Viewer. This is ref counted, because I intend to use the same mechanism for other scenarios, such as when the viewer is visible but nothing is changing.
  • In the createViewerForCanvas function, use IntersectionObserver to detect when the viewer canvas is not in the browser viewport and suspend rendering.
  • Update the test app to be able to toggle on/off extra blank content before/after the element to make it easy to test the outside of viewport scenario.
ViewerOffScreenSuspendRendering.mp4

@ryantrem ryantrem requested review from RaananW and sebavan November 15, 2024 22:11
@bjsplat
Copy link
Collaborator

bjsplat commented Nov 15, 2024

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 15, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 15, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Nov 15, 2024

@ryantrem ryantrem enabled auto-merge (squash) November 16, 2024 18:35
@ryantrem ryantrem merged commit 58343c9 into BabylonJS:master Nov 18, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants