Skip to content

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
Hona merged 1 commit into
devfrom
fix/588-surface-configure
Nov 23, 2026

Conversation

@Hona

@Hona Hona commented Nov 23, 2026

Copy link
Copy Markdown
Member

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.rs and platform/web/frame.rs called Surface::configure directly (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 returned Ok without checking anything.
  • A LayerHost whose drawable stayed Outdated/Lost reported animating on every miss, so the display link spun for as long as the drawable stayed lost.
  • OverlayCore::rescale set the drawable size with a floor of 1 and no ceiling.

What changed

  • window::configure pushes an OutOfMemory scope too.
  • On wasm, window::configure_then configures through the JS device's error scopes on WebGPU (wgpu's own panic on a GPUInternalError) and through wgpu-core's synchronous scopes on WebGL2.
  • The web host's surface state is one state machine, 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)
Loading
  • An answer for an attempt the state no longer holds changes nothing.
  • While it is not Ready, the frame gate skips GPU frames.
  • embed_frame::EmbedSurfaceHealth: after 5 lost drawables in a row, a LayerHost stops reporting animating until a resize or a drawn frame.
  • overlay_rescale_size holds an overlay's drawable to 1..=max_texture_dimension_2d.

Tests

  • window::tests::no_direct_surface_configure_outside_helper: fails on any surface.configure( outside window/surface/configure.rs. On dev it lists the web sites.
  • web_math::tests::surface_health_backs_off_ignores_stale_attempts_and_gives_up_until_resize
  • embed_frame::tests::run_embed_frame_stops_animating_after_consecutive_lost_drawables_until_resize (fails on dev: every miss reports animating).
  • overlay::tests::overlay_rescale_clamps_to_max_texture_dimension
  • Compiled for wasm32 (with and without webgl), macOS and Linux. Nothing here drives a browser.

… error scopes, catch out-of-memory, and back off instead of panicking or spinning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant