-
-
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
Allow Bevy to start from non-main threads on supported platforms #10020
Allow Bevy to start from non-main threads on supported platforms #10020
Conversation
Signed-off-by: Torstein Grindvik <[email protected]>
Signed-off-by: Torstein Grindvik <[email protected]>
crates/bevy_winit/src/lib.rs
Outdated
// This is needed because the X11 feature | ||
// might be enabled for macos too. |
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.
not just on macOS, x11 is enabled by default in Bevy on all platforms
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.
Thanks, new comment is hopefully more correct
Signed-off-by: Torstein Grindvik <[email protected]>
can you add this for windows too? |
Signed-off-by: Torstein Grindvik <[email protected]>
Added. Missed it because for me, https://docs.rs/winit/latest/winit/?search=any_thread does not show Windows 🤔 |
Yeah, this looks good. Just, users need to make sure any non-send resources get initialized in the same thread the app will live in (i.e. construct the app inside the new thread, don't add plugins in the main thread and then move it there). |
I don't have any of the platforms impacted, but it should work as long as winit works 👍 I think it should be configurable by the user |
I initially thought to make it configurable, but then I realized it only enables more flexiblity for the users of the affected platforms. Since as far as I can tell it has no downsides, I see no point in not allowing any thread to start Bevy on platforms which support it. Happy to make it configurable if you want to, in that case could you let me know which way to go:
|
Imo this should be off by default, because a user may not realize that it works only on the platform they're developing on, and then run into issues later when running on a different platform. I'm in favor of a field on the winit plugin. |
Signed-off-by: Torstein Grindvik <[email protected]>
Good point, changed to this behavior now. |
Signed-off-by: Torstein Grindvik <[email protected]>
Head branch was pushed to by a user without write access
@james7132 there was some issues with docs, so changed the doc link slightly but kept it to local symbols. |
…yengine#10020) # Objective Allow Bevy apps to run without requiring to start from the main thread. This allows other projects and applications to do things like spawning a normal or scoped thread and run Bevy applications there. The current behaviour if you try this is a panic. ## Solution Allow this by default on platforms winit supports this behaviour on (x11, Wayland, Windows). --- ## Changelog ### Added - Added the ability to start Bevy apps outside of the main thread on x11, Wayland, Windows --------- Signed-off-by: Torstein Grindvik <[email protected]> Signed-off-by: Torstein Grindvik <[email protected]> Co-authored-by: Torstein Grindvik <[email protected]> Co-authored-by: James Liu <[email protected]>
…yengine#10020) # Objective Allow Bevy apps to run without requiring to start from the main thread. This allows other projects and applications to do things like spawning a normal or scoped thread and run Bevy applications there. The current behaviour if you try this is a panic. ## Solution Allow this by default on platforms winit supports this behaviour on (x11, Wayland, Windows). --- ## Changelog ### Added - Added the ability to start Bevy apps outside of the main thread on x11, Wayland, Windows --------- Signed-off-by: Torstein Grindvik <[email protected]> Signed-off-by: Torstein Grindvik <[email protected]> Co-authored-by: Torstein Grindvik <[email protected]> Co-authored-by: James Liu <[email protected]>
…yengine#10020) # Objective Allow Bevy apps to run without requiring to start from the main thread. This allows other projects and applications to do things like spawning a normal or scoped thread and run Bevy applications there. The current behaviour if you try this is a panic. ## Solution Allow this by default on platforms winit supports this behaviour on (x11, Wayland, Windows). --- ## Changelog ### Added - Added the ability to start Bevy apps outside of the main thread on x11, Wayland, Windows --------- Signed-off-by: Torstein Grindvik <[email protected]> Signed-off-by: Torstein Grindvik <[email protected]> Co-authored-by: Torstein Grindvik <[email protected]> Co-authored-by: James Liu <[email protected]>
Objective
Allow Bevy apps to run without requiring to start from the main thread.
This allows other projects and applications to do things like spawning a normal or scoped
thread and run Bevy applications there.
The current behaviour if you try this is a panic.
Solution
Allow this by default on platforms winit supports this behaviour on (x11, Wayland, Windows).
Changelog
Added