-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
LogPlugin
silently overwrites the panic hook in WASM
#12546
Comments
Why was this added in the first place? Can you check through the git history and link the PR? |
I believe it was added as a default to give WASM users the stack trace in their console, instead of the cryptic It's been untouched since the original LogPlugin PR, 4 years ago, by @cart I think the reason it has gone unnoticed for so long is probably that it's uncommon and fairly technical to implement your own WASM panic handler. @Vrixyz and I just made the I would love to hear @cart 's original intention with this - and whether we can remove it. Should this logic be a separate |
Thanks for the detective work! Splitting this out so it can be disabled or overwritten seems like a sensible direction to me. No strong feelings on the exact architecture though. |
This is probably the case. According to |
@alice-i-cecile - Went ahead with the separate plugin strategy outlined above. PR #12557 |
# Objective - Allow configuring of platform-specific panic handlers. - Remove the silent overwrite of the WASM panic handler - Closes #12546 ## Solution - Separates the panic handler to a new plugin, `PanicHandlerPlugin`. - `PanicHandlerPlugin` was added to `DefaultPlugins`. - Can be disabled on `DefaultPlugins`, in the case someone needs to configure custom panic handlers. --- ## Changelog ### Added - A `PanicHandlerPlugin` was added to the `DefaultPlugins`, which now sets sensible target-specific panic handlers. ### Changed - On WASM, the panic stack trace was output to the console through the `BevyLogPlugin`. Since this was separated out into `PanicHandlerPlugin`, you may need to add the new `PanicHandlerPlugin` (included in `DefaultPlugins`). ## Migration Guide - If you used `MinimalPlugins` with `LogPlugin` for a WASM-target build, you will need to add the new `PanicHandlerPlugin` to set the panic behavior to output to the console. Otherwise, you will see the default panic handler (opaque, `unreachable` errors in the console).
The
LogPlugin
silently overwrites the panic handler on WASM. This means if you attempt to set your own panic handler, or use something like https://github.com/vectorgameexperts/web_panic_report, you have to overwrite it on Startup (thus, your panic handler can't be added until Startup)Problematic code:
bevy/crates/bevy_log/src/lib.rs
Lines 206 to 212 in 5d0ff60
This should not be considered acceptable default behavior.
3 options here, open to discussion.
bevy/crates/bevy_log/src/lib.rs
Lines 136 to 140 in 5d0ff60
The text was updated successfully, but these errors were encountered: