Repository navigation
fix(wasm): Avoid stuck loading screen on startup - #23590
Conversation
The Skia WebAssembly render pump is driven by requestAnimationFrame. RenderFrame() cleared _pendingInvalidate before the readiness guard and returned without rescheduling when RootElement was not ready yet, so the single queued frame was lost. Combined with render-request deduplication, nothing re-armed the pump and the splash screen (gated on FrameRendered) was never removed, leaving mobile and background-tab loads stuck near 100%. Re-arm an animation frame in the not-ready branch while a request is still pending, so it survives until RootElement is ready and the pump self-heals. Fixes #23586 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014gUKcEenvQ1Tn9t1zDFUm7
|
Claude finished @MartinZikmund's task in 2m 58s —— View job Review complete
SummaryVerdict: LGTM with one minor suggestion — 0 blocking issues, 1 minor style nit. The root cause analysis in the PR description is accurate. The fix is well-targeted:
Test coverage — the checklist item is unchecked and the author's rationale (the race needs a testable seam extracted as a follow-up) is reasonable. A note: the JS override snippet in the PR description is a good manual repro; wiring an One inline suggestion posted — trimming the 4-line comment block to 2 lines and removing the |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23590/wasm-skia-net9/index.html |
GitHub Issue: closes #23586
PR Type:
🐞 Bugfix
What changed? 🚀
On the Skia WebAssembly target, apps frequently stayed on the bootstrap loading screen (stuck near 100%) on mobile — almost always on iOS, ~half the time on Android — and on desktop when the tab was backgrounded/minimized during load (requiring an F5). The app was fully running; only the first frame never painted, so the persistent bootstrap loader (kept alive until the app reports its first render) was never removed.
Root cause
The Skia WebAssembly render pump is driven by
requestAnimationFrame:InvalidateRender → requestAnimationFrame → RenderFrame.BrowserRenderer.RenderFrame()reset_pendingInvalidate = falseat the very top, then early-returned whenRootElement/CompositionTargetwas not ready yet (which happens when a frame fires before app initialization completes — common on slower mobile startups and in throttled background tabs). The queued animation frame was therefore consumed without painting and without rescheduling.Because
CompositionTarget.RenderRequestedis only cleared once a render actually happens, it stayedtrue, so the compositor never issued anotherInvalidateRender; and the render-request deduplication (_pendingInvalidate) meant nothing re-armed the pump. Splash removal is gated on theFrameRenderedevent, which never fired — so the loader stayed forever. A touch/drag/scroll/resize revived it only because the TypeScriptsetCanvasSize() → invalidate()path bypasses the deduplication.This was a regression:
release/stable/6.5contains neither the readiness guard (d5c6aa12de) nor the deduplication (d2bfc671ad). Before the dedup, everyInvalidateRenderqueued its own frame, so a dropped tick self-healed on the next one.Fix
In
RenderFrame(), move the_pendingInvalidate = falsereset below the readiness guard, and in the not-ready branch re-arm another animation frame — but only while a render is genuinely pending (_pendingInvalidate == true), so the deduplication-bypassing TypeScript resize ticks can't cause a busy-loop. The pending request now survives untilRootElementis ready, at which point it paints and removes the splash. This self-heals both the mobile first-load race and the desktop background-tab case (a re-armed frame stays queued across rAF throttling and runs on refocus), with novisibilitychangehandler needed.Verified against the other Skia hosts (Win32/X11/Android) — they use continuous frame-pacers and don't have this self-consuming one-shot, so they were never affected and remain unchanged.
PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code