rust-windowing / winit

Window handling library in pure Rust

Home Page:https://docs.rs/winit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom cursor (from_rgba) set in response to non-CursorMoved event leads to "already borrowed" panic when resizing

benjamin-sieffert opened this issue · comments

Description

This is on web running in Firefox on Linux with WGPU for rendering (both nightly for webgpu and regular for webgl, have same issue).

  • Create cursor data with CustomCursor::from_rgba (bytes available via include_bytes!)
  • Create custom cursor with event_loop.create_custom_cursor(data)
  • Now start the application with event_loop.spawn
  • Activate the cursor by calling set_cursor on the Arc<Window> - do this all the time when handling input events
  • When resizing the window (canvas) now, it will produce already borrowed: BorrowMutError

Specifically:

panicked at /home/ax/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.30.0/src/platform_impl/web/web_sys/resize_scaling.rs:90:44:
already borrowed: BorrowMutError

I am calling set_cursor outside any ongoing rendering passes or presentations, but (necessarily) during an event handling.
Obviously the problem can be greatly alleviated by not calling set_cursor all the time (but only when it actually changes) - but then the panic would only be much rarer, not fixed.


I can also write a reproducer, if required.
No panic happens when running the same code on native Linux.

The documentation uses from_url over from_rgba on web, but there is no explicit statement about the rgba version being bad on web; and the API is enabled, so I presume it should work.
(I did not test whether from_url makes the problem go away.)

Tested browsers

Firefox

Tested devices

Desktop PC,
Firefox on Linux with wgpu for rendering
(both nightly for WebGPU backend and regular firefox for WebGL backend, have same issue)

Winit version

0.30.0

I can say with some certainty that the code in Winit is correct and this could never trigger, so it sounds to me again like a bug in Firefox (#1 #2 #3).

A minimal reproducible example would be very appreciated.