WASM canvas resize: skip with_surface_size on wasm (alt to #431)#432
Merged
nicoburns merged 1 commit intoMay 12, 2026
Merged
Conversation
…#431) Alternative implementation of Nico's hypothesis on DioxusLabs#431. Instead of stripping the inline `canvas.style.width/height` that winit-web writes, drop the `.with_surface_size(...)` call on wasm entirely so the styles never get set in the first place. Host CSS controls the canvas box. Three pieces in one branch: - Examples (seven_guis, todomvc, wasm_hello) no longer call `.with_surface_size(...)` on wasm; the seven_guis and todomvc `index.html` files get `canvas { width: 100%; height: 100% }` so the canvas fills the viewport once winit isn't pinning it. - `View::init` falls back to reading the canvas's CSS layout box (`offset_width × offset_height × devicePixelRatio`) when winit-web's initial `surface_size()` is 0×0 — without this, wgpu fails with a swapchain-size-0 error before the first ResizeObserver fires. - Same wgpu `surface.configure` debounce as DioxusLabs#431, with a coalesce guard so a continuous browser-window drag schedules one timer instead of one per `SurfaceResized`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
@nicoburns request review |
nicoburns
approved these changes
May 12, 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.
Alternative to #431 implementing @nicoburns's hypothesis: drop
.with_surface_size(...)on wasm so winit-web never writes inlinecanvas.style.width/height, letting host CSS size the canvas directly — no style-stripping needed. Same wgpusurface.configuredebounce as #431 (with timer coalescing to avoid closure leaks during drag), plus a fallback that seeds the initial size from the canvas's CSS layout when winit-web reports 0×0 at init.