-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
eframe on the web (egui_web) creates a mess on panic #1290
Comments
You can run this app in your browser using the following link and see the problem yourself by clicking the panic button on the left sidebar. |
This is not a solution, but it can be helpful to use https://github.com/rustwasm/console_error_panic_hook and https://crates.io/crates/tracing-wasm for better console logs. I don't have the time to dive into this at the moment - would you like to take a stab at it? I wonder if there is a standard solution to this problem. In what state is the WASM app (egui) left in after a panic? Is any callback into it always a problem? |
I will take a stab at it. I already have an idea of a solution, I will just have to familiarize myself with the code. |
add destroy function to egui_web and call it in panic handler maybe helpful in this case. |
…1306) Closes: #1290 Fix panic reported by @Titaniumtown See #1306 (comment)
Describe the bug
When using eframe on the web (wasm), you call
eframe::start_web
to set eframe up.eframe::start_web
installs many event callbacks into the DOM and a 1 second interval callback which are all used to render/update the application. This is fine and works perfectly when the application is in a valid state.Because these callbacks call into rust code from the JS engine, when rust code panics from anything (in my example I use an explicit panic to show the behavior), the state of the rust code becomes undefined but the JS engine will continue to call into the wasm code, unaware that it has panicked. This leads to a spam of errors in the console which can be seen in the screencap below:
Uncaught RuntimeError: unreachable executed
.This causes multiple problems:
console_error_panic_hook
would be hidden away by the error spamRuntimeError
s which will slow down a browser's devtools and lead to a very unfriendly user experience.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The application would panic, printing the message to the console and would stop responding to user events.
to achieve this eframe could provide a way to de-register the callbacks registered in
eframe::start_web
that can be called in a panic handler, oreframe_web
could provide/set a panic handler to do this without the need for a programmer to call the function themselves.Screenshots
recordedVideo.mp4
Desktop (please complete the following information):
Additional context
The code for this can be found here and is built using trunk, but trunk should not affect the behavior of eframe.
The text was updated successfully, but these errors were encountered: