Comments (6)
The behavior is probably caused by running the component runtime as a future on the glib runtime (through spawn_local). The only way to improve on this would be to add our own unwind catcher and terminate the app from there, if desired by the user.
from relm4.
Are you saying there wouldn't be a way to propagate errors up to a user-defined function? I'm wanting to capture panics in my main()
function, does using spawn_local
not provide a good way of doing that?
from relm4.
Mentioning my use case to try to give some clarity on what I'm trying to do, but I'd like to capture all panics in my application from main()
, and then upload those panics to a service for further inspection. My application was previously written in GTK4/Libadwaita directly and I was able to do such with relative ease, but from what you're saying I'm not sure if you're thinking it's possible.
from relm4.
Most async runtimes capture panics in tasks and I think glib does that too. This is done to prevent a single task from terminating the entire app. Unfortunately, this is what you want in your case.
What I was thinking is to add a panic handler to the Component
trait that gets called when something in the component panics. From there, you could stop the app and also do whatever is necessary to send crash reports.
from relm4.
I think the cleanest approach would be for nothing to capture panics, and for them to always just propogate all the way back up the stack.
I don't really like the idea of having to add a panic handler to each Component
individually. I'd also like to capture all panics, even those that happen to not be inside/related to Component
code (i.e. if a bug in Relm4 caused a panic, I'd want to catch that as well).
I'm thinking of filing an issue with the upstream glib
crate to see how feasible it would be to add some sort of functionality to disable panic capturing. Is there anything else you'd think might work for a clean implementation though?
from relm4.
Alright, I think I've figured out a pretty good solution to my issue:
As mentioned at gtk-rs/gtk-rs-core#1229 (comment), letting panics go all the way back up to my main()
function isn't much of an option since glib
has code that isn't unwind-safe.
Since I just needed to capture panics on a global level, I've found this solution to work just fine though:
- Set
panic = "abort"
inCargo.toml
, so that panics always immediately shut everything down. - Have the following code get placed, which allows for panics to still be captured:
std::panic::set_hook(Box::new(|info| {
...
}));
I didn't know std::panic::set_hook
could still run on panic::abort
, but since it does it looks like that'll solve my issue pretty cleanly.
This should be pretty much solved for me, feel free to close it if there isn't anything else you want looked at with it.
from relm4.
Related Issues (20)
- `transient_for` errors in child component HOT 2
- Missing Trait Implementations for `FlowBox` and Potential Conflicts HOT 2
- Resizeable and expandable columns with TypedColumnView HOT 2
- Replace `this` with `model` in factory
- Support `match` at the top root of the widget
- Make #[local_ref] support expressions
- Just tested, weird behavior HOT 1
- OpenDialog : how to select file in root of disk HOT 1
- Add `extend` method for `FactoryVecDeque`
- Add option to disable RelmAction
- GLib-GIO-CRITICAL **: 23:02:38.707: This application can not open files. HOT 1
- Support for `libadwaita::ToolbarView`? HOT 3
- ProgressBar did not show up as expected. HOT 4
- [email protected] depends still on [email protected] HOT 1
- gtk::MessageDialog is deprecated in favor of gtk::AlertDialog HOT 2
- FactoryVecDeque will eventually crash due to memory leaks HOT 7
- All versions after 0.6.2 include libadwaita by default HOT 5
- Allow customizing stack properties
- i want to override window exit event but how can i do HOT 1
- GLib-GObject-CRITICAL on shutdown of app with root SimpleAsyncComponent and AsyncController with adw::PreferencesWindow HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from relm4.