wasm improvements

This commit is contained in:
Jorijn van der Graaf 2026-08-05 04:08:13 +02:00
commit 6aa0338c0f
9 changed files with 603 additions and 70 deletions

View file

@ -121,7 +121,22 @@ export namespace Crafter {
~Window();
#endif
// Enter the platform event loop and never return. In DOM mode this
// hands the loop to requestAnimationFrame and _Exit(0)s so the wasm
// instance survives without running static destructors. No caller
// code after this point ever runs, on any target.
void StartSync();
// As StartSync, but does NOT start the animation-frame loop in DOM
// mode — for event-driven pages that only touch the DOM and never
// draw. A rAF tick running forever to do nothing costs battery in
// every open tab. Still never returns.
//
// On native this is identical to StartSync: the event loop is what
// keeps a window alive there, so there is no cheaper option. Call it
// unconditionally and get the browser saving without an #ifdef.
void StayAlive();
void StartUpdate();
void StopUpdate();
void SetTitle(const std::string_view title);