-
Notifications
You must be signed in to change notification settings - Fork 947
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
Panic on multiple EventLoop instantiation, document why #2344
Panic on multiple EventLoop instantiation, document why #2344
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much of anything to point out beyond what @kchibisov has already done. I would like a better panic message, but I can't seem to formulate something that's both unambiguously better and doesn't remove the "this isn't supported" part right now.
…ssage, re-order imports
Just in case anyone comes across this error on Android: Its framework can launch multiple activities inside the same process. This activity start however pretends to be like a That's not something caused by this PR though, rather it's highlighting the underlying issues that we have yet to resolve ;) |
We could have platform specific methods to avoid this error, like |
Please no. This is "yet another When does this happen? Depends on how Android launches the users' activity; on my phone it at least relaunches when switching the app (in)to a so-called "pop-up window", allowing me to "test" resizes (and it took a while to understand why it was completely and utterly broken 😬). |
Should we clear the static on |
I think some platforms(macOS/ios) will abort if you try to recreate the event loop, the error is for a particular functions to prevent cross platforms issues, however we can provide separate methods that allow event loop recreation. |
@kchibisov Platform-specific extensions would be ok. I just thought it might be cleaner to clear the With the current API, is it possible to attempt to recreate the event loop on macOS and iOS without having to go through one of the non-portable paths (e.g. |
EventLoop creation and dropping is complicated topic wrt recreation since system libraries to initialize some global state most of the time. On drop it usually persist or something else has non-null state, etc, etc. So I'm not sure what needs to be documented, in fact I'm not sure there're platforms safely allowing event loop recreation, most of the time it's never tested and if it works you're lucky. |
Yeah I agree with that. I mean you can't normally return from On the web it can be a bit tricky avoiding recreating the event loop (e.g. single page application that uses winit on a single tab). Even though we're using |
Well, for |
I've been using I'm ok with adding platform-specific extensions to handle this use case. I thought it might be cleaner to clear the |
I think we can probably clear it from |
CHANGELOG.md
if knowledge of this change could be valuable to usersSince it was extremely easy to implement using existing dependencies I just made a prototype implementation that agressively fixes #2166.
In the issue discussions were around just documenting it, or making it panic. I'm more for making it panic immediately since the problems can be hard to diagnose if they occur "naturally" such as in the report of a segfault, with other example in that same issue of SendErrors. Getting a segfault and tracking it down to EventLoopBuilder's docs will probably waste a lot of time for users.
I'm not ecstatic about having a static OnceCell to guard against double instantiation, but I can't think of any smoother solution