-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Summary
Activity starts a recursive requestAnimationFrame(renderLoop) that runs for the full page lifetime, but there is no tracked RAF id/cancel path for this loop.
Code references
js/activity.js:504(const renderLoop = () => { ... })js/activity.js:514(requestAnimationFrame(renderLoop);inside loop)js/activity.js:516(initialrequestAnimationFrame(renderLoop);)
Why this matters
Even with dirty-checks, the RAF callback itself still executes every frame. Without explicit lifecycle cleanup, this can:
- keep scheduling work when Activity is torn down/reinitialized,
- create duplicate loops in edge re-init flows,
- waste CPU on low-power devices.
Expected behavior
- Store RAF id (e.g.
this._renderLoopRafId) when scheduling. - Gate loop with a lifecycle flag (e.g.
this._isRunning). - Cancel RAF on teardown/destroy path (
cancelAnimationFrame).
Suggested fix sketch
- Replace naked recursive calls with a managed
startRenderLoop()/stopRenderLoop()pair. - Ensure
stopRenderLoop()is invoked from Activity cleanup/unload hooks.
Optional validation
- Add a unit/integration check that reinitializing Activity does not increase active RAF loop count.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels