-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
AppExit should return from App::run without quitting the process #167
Comments
This might be unresolvable, due to how |
In that case it might make sense to have |
This is a tough one. On the one hand, I like knowing when code is unreachable. On the other hand, for apps that dont need winit, I'm not sure I want to prevent them from being used within a larger context. Ideally we can find a way to make winit return. If not I'm inclined to leave the current behavior the way it is, despite the slightly confusing divergent behavior. I'm happy to discuss this more though. |
Ex: allowing Apps to return makes it much easier to write unit tests |
For what it's worth, it's possible to have it return on desktop targets (where most unit testing should/will happen, I think), but there are caveats, as outlined in the link. Perhaps a variant of the plugin, for testing and that one inevitable odd setup that cannot live without it? |
@Ratysz Thank you for that link. I was digging in the winit code a bit trying to see if it was configurable but that was the piece I was missing. I took a look at the macos implementation of run to understand the difference between |
Here's a similar closed issue in winit that goes into some detail about the design decision there. One caveat that I think we should be aware of as consumers of winit is that if there is anything in scope that is not captured by the closure passed in to |
So I've given this a bit of thought and I think it'd be great to add an extension on to This would let us use it in tests as well as let clients of Bevy make an informed decision for their projects. I'd write similar caveats into the documentation for the new API linking to the caveats in the dependency. @Ratysz, @cart what do you think? If that sounds good I'd be happy to take the issue. |
I think that shouldn't be tacked on to App, but rather passed into winit via a configuration Resource of some kind (ex: I'm cool with giving people choices. It seems pretty clear (given the winit docs) that the default should remain as it is though. So yeah that sounds good to me! |
Yes it is necessary |
This adds a new WinitConfig resource that con be used to configure the behavior of winit. When `return_from_run` is set to `true` the App::run() will return on target_os configurations that support it. On non-desktop targets the `return_from_run` setting is ignored. Closes bevyengine#167.
This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. On non-desktop targets the `return_from_run` setting is ignored. Closes bevyengine#167.
This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. On non-desktop targets the `return_from_run` setting is ignored. Closes bevyengine#167.
This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. On non-desktop targets the `return_from_run` setting is ignored. Closes bevyengine#167.
This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. On non-desktop targets the `return_from_run` setting is ignored. Closes bevyengine#167.
This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. Closes bevyengine#167.
…bevyengine#243) This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. Closes bevyengine#167.
… (#243) This adds a new WinitConfig resource that can be used to configure the behavior of winit. When `return_from_run` is set to `true`, `App::run()` will return on `target_os` configurations that support it. Closes bevyengine/bevy#167.
It seems a bit counter intuitive that when default plugins are added,
App::run()
is effectively a diverging function that never returns. This means that any code after the call toApp::run()
is silently ignored.With
add_default_plugins
prints:
When the window is closed, the process exits and
App::run()
never returns.Without
add_default_plugins
In the
hellow_world.rs
example that doesn't add default plugins this behaves more as I would expect:prints:
Conclusion
In my opinion the most intuitive behavior would be if the
AppExit
event just caused theApp::run()
function call happening on the main thread to return control (as it does in thehello_world
example).The text was updated successfully, but these errors were encountered: