Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
benjamin-sieffert opened this issue May 1, 2024 · 1 comment
Labels
B - bug Dang, that shouldn't have happened DS - web

Comments

@benjamin-sieffert
Copy link

benjamin-sieffert commented May 1, 2024

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

@benjamin-sieffert benjamin-sieffert added B - bug Dang, that shouldn't have happened DS - web labels May 1, 2024
@daxpedda
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened DS - web
Development

No branches or pull requests

2 participants