Repository navigation
fix(surface): web and LayerHost surface configures go through guarded error scopes, catch out-of-memory, and back off instead of panicking or spinning - #1586
Merged
Conversation
… error scopes, catch out-of-memory, and back off instead of panicking or spinning
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #588
Part 1 of #588: a refused surface configuration no longer panics on the web or spins a LayerHost.
What was wrong
platform/web/gpu.rsandplatform/web/frame.rscalledSurface::configuredirectly (3 sites). A refusal went to wgpu's default handler, which panics.window::configure(window/surface/configure.rs) scoped validation and internal errors, but not out-of-memory ones. On wasm it returnedOkwithout checking anything.LayerHostwhose drawable stayedOutdated/Lostreportedanimatingon every miss, so the display link spun for as long as the drawable stayed lost.OverlayCore::rescaleset the drawable size with a floor of 1 and no ceiling.What changed
window::configurepushes anOutOfMemoryscope too.window::configure_thenconfigures through the JS device's error scopes on WebGPU (wgpu's own panic on aGPUInternalError) and throughwgpu-core's synchronous scopes on WebGL2.web_math::SurfaceHealth:stateDiagram-v2 Ready --> WaitingRetry: refused (50 ms, doubling) WaitingRetry --> Ready: RetryDue(attempt) -> configure WaitingRetry --> GaveUp: 5th refusal in a row GaveUp --> Ready: Resized Ready --> Ready: Presented (failures = 0)Ready, the frame gate skips GPU frames.embed_frame::EmbedSurfaceHealth: after 5 lost drawables in a row, a LayerHost stops reportinganimatinguntil a resize or a drawn frame.overlay_rescale_sizeholds an overlay's drawable to1..=max_texture_dimension_2d.Tests
window::tests::no_direct_surface_configure_outside_helper: fails on anysurface.configure(outsidewindow/surface/configure.rs. On dev it lists the web sites.web_math::tests::surface_health_backs_off_ignores_stale_attempts_and_gives_up_until_resizeembed_frame::tests::run_embed_frame_stops_animating_after_consecutive_lost_drawables_until_resize(fails on dev: every miss reportsanimating).overlay::tests::overlay_rescale_clamps_to_max_texture_dimensionwebgl), macOS and Linux. Nothing here drives a browser.