fix(emscripten): stop the rAF draw loop outliving the window (#184) #185

Merged
OragonEfreet merged 1 commit from fix/184 into main 2026-10-15 21:15:48 +02:00
Owner

em_on_frame re-armed requestAnimationFrame whenever damage_pending was
set at the end of a frame, and nothing ever cancelled a pending rAF.
After the app quit (or any window lifetime ended without cancellation),
the draw loop kept firing on freed memory and presented black/stale
frames over the live embed — on the 1976 Breakout blog page ~93% of
putImageData calls were black and the canvas flickered.

  • Add a dead tombstone on the emscripten window, set by
    emscripten_window_del before the free; every new window clears it.
  • em_on_frame refuses to fire the draw or re-arm once dead.
  • emscripten_request_redraw ignores dead windows.
  • Track the rAF handle (raf_id) and cancel it in emscripten_window_del;
    the browser never cancels a pending rAF by itself.
em_on_frame re-armed requestAnimationFrame whenever damage_pending was set at the end of a frame, and nothing ever cancelled a pending rAF. After the app quit (or any window lifetime ended without cancellation), the draw loop kept firing on freed memory and presented black/stale frames over the live embed — on the 1976 Breakout blog page ~93% of putImageData calls were black and the canvas flickered. - Add a dead tombstone on the emscripten window, set by emscripten_window_del before the free; every new window clears it. - em_on_frame refuses to fire the draw or re-arm once dead. - emscripten_request_redraw ignores dead windows. - Track the rAF handle (raf_id) and cancel it in emscripten_window_del; the browser never cancels a pending rAF by itself.
OragonEfreet added this to the 1.1 milestone 2026-10-15 21:12:12 +02:00
fix(emscripten): stop the rAF draw loop outliving the window
All checks were successful
C++ Compatibility / C++ Compatibility Check (push) Successful in 8s
Documentation / build-docs (push) Successful in 10s
QA / cert (push) Successful in 30s
Build and Test / linux-linux-gcc / shared (push) Successful in 17s
Build and Test / linux-linux-gcc / static (push) Successful in 18s
Build and Test / linux-windows-mingw / shared (push) Successful in 29s
Build and Test / linux-windows-mingw / static (push) Successful in 30s
C++ Compatibility / C++ Compatibility Check (pull_request) Successful in 8s
Documentation / build-docs (pull_request) Successful in 12s
QA / cert (pull_request) Successful in 35s
Build and Test / linux-linux-gcc / shared (pull_request) Successful in 19s
Build and Test / linux-linux-gcc / static (pull_request) Successful in 19s
Build and Test / linux-windows-mingw / shared (pull_request) Successful in 29s
Build and Test / linux-windows-mingw / static (pull_request) Successful in 29s
349ab4b040
em_on_frame re-armed requestAnimationFrame whenever damage_pending was
set at the end of a frame, and nothing ever cancelled a pending rAF.
After the app quit (or any window lifetime ended without cancellation),
the draw loop kept firing on freed memory and presented black/stale
frames over the live embed — on the 1976 Breakout blog page ~93% of
putImageData calls were black and the canvas flickered.

- Add a dead tombstone on the emscripten window, set by
  emscripten_window_del before the free; every new window clears it.
- em_on_frame refuses to fire the draw or re-arm once dead.
- emscripten_request_redraw ignores dead windows.
- Track the rAF handle (raf_id) and cancel it in emscripten_window_del;
  the browser never cancels a pending rAF by itself.
OragonEfreet deleted branch fix/184 2026-10-15 21:15:48 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
OragonEfreet/banjo!185
No description provided.