Skip to content

fix(canvas): don't hold SurfaceData mut borrow over window resize#35993

Merged
bartlomieju merged 6 commits into
denoland:mainfrom
Giesch:fix/byow-surface-resize-double-borrow
Jul 15, 2026
Merged

fix(canvas): don't hold SurfaceData mut borrow over window resize#35993
bartlomieju merged 6 commits into
denoland:mainfrom
Giesch:fix/byow-surface-resize-double-borrow

Conversation

@Giesch

@Giesch Giesch commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #35992. I've used Claude Code while working on this PR.

The original issue was a panic when resizing a window when using the raw webgpu desktop backend. This change addresses that by explicitly dropping the RefMut used to modify the width/height.

The added test opens a real FFI window. If that's undesirable, then we could potentially remove it. But, I think the alternative test would be a more invasive change to set up mockable traits for windowing, which might be even less desirable.
The intent is that the X11 version of the test is optional, and that the Windows version is required for CI. I'm not able to try out the Windows version locally right now, though. We'll need to check the PR's CI run.

One broader change that might be a better alternative than this fix would be to change width and height into plain Cell<u32> properties, with no runtime borrow-checking. There's already no atomicity between width and height, and it seems like the other properties are intended to be read-only. That would make the test redundant, because the panic would no longer be possible.

@deno-cla-assistant

deno-cla-assistant Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deno Individual Contributor License Agreement

All contributors have signed the CLA. Thank you!

Re-run CLA check


This is an automated message from CLA Assistant

@Giesch
Giesch force-pushed the fix/byow-surface-resize-double-borrow branch from 3574364 to 778543f Compare July 12, 2026 20:40
Giesch and others added 2 commits July 12, 2026 20:56
Adds a unit test that creates a real native window over FFI (win32 or
x11), configures a webgpu context on a Deno.UnsafeWindowSurface, and
resizes it. Without the previous commit, the width/height setters panic
with a RefCell double borrow when the configured context is resized.

Also passes --unstable-webgpu to webgpu_test in the unit test harness;
without it Deno.UnsafeWindowSurface is undefined, and the existing
UnsafeWindowSurface tests only passed because constructing undefined
also throws.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Giesch
Giesch force-pushed the fix/byow-surface-resize-double-borrow branch from ed1bc13 to a9e3c66 Compare July 13, 2026 02:20
…m [ci]

Moves the windowing-system availability check to the top level of
webgpu_test.ts so the resize regression test is reported as ignored
instead of silently passing, and makes in-test window creation failures
explicit test failures. Also pins the expected error type and message
in the UnsafeWindowSurface constructor tests.

Co-Authored-By: Claude Fable 5 <[email protected]>
@crowlKats
crowlKats self-requested a review July 13, 2026 13:32
@crowlKats crowlKats linked an issue Jul 13, 2026 that may be closed by this pull request
@Giesch
Giesch marked this pull request as ready for review July 13, 2026 15:16
Comment thread ext/canvas/byow.rs Outdated
Comment thread ext/canvas/byow.rs Outdated
Giesch and others added 2 commits July 13, 2026 19:06
Co-authored-by: Kenta Moriuchi <[email protected]>
Signed-off-by: Dan Gieschen Knutson <[email protected]>
Co-authored-by: Kenta Moriuchi <[email protected]>
Signed-off-by: Dan Gieschen Knutson <[email protected]>

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@bartlomieju
bartlomieju merged commit 70dba84 into denoland:main Jul 15, 2026
136 checks passed
bartlomieju pushed a commit that referenced this pull request Jul 15, 2026
…5993)

Fixes #35992

---------

Signed-off-by: Dan Gieschen Knutson <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Kenta Moriuchi <[email protected]>
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.

desktop: raw backend panics on window resize desktop: error-report HTTP client not initialized; dropping report

3 participants