Skip to content

Bevy, on Web and WebGL, doesn't exit winit's Event Loop cleanly after a GPU crash. It panics twice with already borrowed: BorrowMutError #12979

Open
@maximetinu

Description

@maximetinu

Bevy version

Latest released Bevy atow, which is 0.13.2

This can be reproduced at the Bevy examples posted on the web

Relevant system information

I am able to reproduce this both with Google Chrome and Firefox, both in a M1 Macbook and a Windows 11 laptop

What you did (repro steps)

image
  • Click on the example canvas to gain focus
  • Press P to panic, as usual
  • You will see an error like this. This is normal and expected, it's a deliberated panic, part of the example:
image

Now, let's reproduce the actual issue

image

Unexpected behaviour comes here.

  • Instead of showing only 1 panic: the panic that occurred
  • FAIL: It shows an additional BorrowMutError panic. See:
image

wasm_example.js:502 panicked at [...]/winit-0.29.15/src/platform_impl/web/event_loop/runner.rs:625:30: already borrowed: BorrowMutError

What went wrong

- what were you expecting?
I was expecting to see a single crash. This is needed in production environments to uniquely report crashes for analytics and error tracking, and avoiding redundancies.

- what actually happened?
Winit seems to be exiting the event loop in a wrong way, causing yet another panic, which is then handled by the console_error_panic_hook and logged as well

Additional information

  • As an alternative to simulating a GPU crash by calling the WebGL2 extension, in Google Chrome, we can also write chrome://gpucrash/ in the address bar and press enter to simulate it at a browser level. Same happens
  • This can't be reproduced on the WebGPU example because WebGPU doesn't crash upon a GPU context loss
  • I'm opening the issue here instead of on Winit's repo because, since Winit web examples don't use WebGL nor graphics, I couldn't reproduce this on them.
  • Update: I've tried setting up a minimal Winit loop example that crases when losing the WebGL context, and I haven't been able to reproduce this, which suggests it may be caused by Bevy, or by how Bevy sets up the Winit's loop?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WindowingPlatform-agnostic interface layer to run your app inC-BugAn unexpected or incorrect behaviorO-WebSpecific to web (WASM) buildsO-WebGL2Specific to the WebGL2 render APIP-CrashA sudden unexpected crash

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions