Description
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)
- Open this link: https://bevyengine.org/examples/Application/logs/
- Open the JS console on the devtools (you can press F12)
- Disable info logs to not clutter your console with the messages that the example logs every frame

- 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:

Now, let's reproduce the actual issue
- Refresh the page, click to gain focus. Now, instead of pressing P:
- Write this into the JS console to simulate a GPU crash
document.querySelector("#bevy").getContext('webgl2').getExtension("WEBGL_lose_context").loseContext()
- The example will crash, this is expected too, it is a known issue. For reference, see:
- The crash will of course be related to
wgpu
,glow
, and graphics code, like this:

Unexpected behaviour comes here.
- Instead of showing only 1 panic: the panic that occurred
- FAIL: It shows an additional
BorrowMutError
panic. See:

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?