question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render loop in live examples in the documentation wastes energy

See original GitHub issue

Many pages in the documentation contain live examples, which are really useful initially to understand the concepts behind the described classes.

But even after I’m finished playing with them, they continue to continuously re-render (sometimes even the same still frame) and waste energy by hogging the CPU and GPU. This is especially noticeable on a laptop, where the used energy raises the temperature and reduces battery life. Even more critical, this will sooner or later trigger CPU throttling, which interferes with estimating the performance of my own code while leaving the documentation open in another browser window.

The simplest solution would be to add a button to pause the render loop of the examples.

A more elegant solution would be to render on-demand, when the user changes one of the controls. The render loop would only run free when one of the controls explicitly enabled an animation. This is less likely to be copy-paste-able into every example, like a generic pause button.

My ideal solution would have the documentation available as documents, as opposed to being locked up in a SPA. The problem would then not even arise unless I enable JavaScript for the threejs.org domain. Unfortunately, I don’t know how much effort this is. This could be as trivial as replacing the # in the URLs with /. Or it could require changing the entire concept of how the documentation is presented.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Hectatecommented, Aug 26, 2020

A quick test in Firefox (79.0 64-bit) seems to indicate that the scene being not visible in the viewport had no impact on this. The Performance tab of Dev Tools showed requestAnimationFrame being called while it was both on and off screen.

In contrast, the same test in Chrome (84.0.4147.135 64-bit) showed no frames being rendered while the iframe was out of the viewport (performance test tab is not the same between these two, but enough to see what was going on under the hood).

In short, browser behavior is a factor here. I didn’t check to see if Firefox has an option to change this behavior.

1reaction
Mugen87commented, Aug 20, 2020

Sorry, but I don’t think we should complicate things and instead keep the documentation simple. Additional controls that allow to start/stop the animation seem over-engineering to me. The fact that animated demos are more expensive to render than on-demand rendering is an acceptable tradeoff.

I mean that reading the documentation should be possible without enabling JavaScript.

Support the documentation with disabled JS is another topic and unrelated to the issue’s title. This request can only be solved by developing a new documentation from scratch. And I doubt it’s worth doing so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation for Greenhouse Gas Emission and Energy ...
GUIDE TO WARM DOCUMENTATION. The documentation provided in this file explains the data, methods, and calculations behind the. WARM greenhouse gas (GHG) ...
Read more >
Life Out Of Plastic - L.O.O.P. - Peru | UNFCCC
Overall, L.O.O.P. foments plastics recycling throughout all of its activities (products, services, and awareness campaigns). This indirectly diverts waste from ...
Read more >
LifeWiki - Conway's Game of Life
It is the best-known example of a cellular automaton. The "game" is actually a zero-player game, meaning that its evolution is determined by ......
Read more >
Slow rendering - Android Developers
UI Rendering is the act of generating a frame from your app and displaying it on the screen. To ensure that a user's...
Read more >
Implementing Conway's Game of Life - Rust and WebAssembly
We can represent the universe as a flat array that lives in the WebAssembly linear memory, and has a byte for each cell....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found