-
Notifications
You must be signed in to change notification settings - Fork 920
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
winitrequires control over the principal class. You must create the event loop before other parts of your application initialize NSApplication #3772
Comments
I've encountered this recently and found a solution for my case that involved using Winit through Slint and Under macOS, the windowing event loop must be started from the main thread, as otherwise AppKit crashes the process. Furthermore, it must also be started before any other such constructs, as otherwise Winit crashes the process on a panic here: winit/src/platform_impl/apple/appkit/event_loop.rs Lines 212 to 223 in dfea49f
where it checks that the returned class is the correct one instead of working on incorrect data, most probably due to AppKit global state. I was able to fix my case by ensuring Winit's event loop was always started first and before If the other event loop is out of your control, it could be a Bevy-specific issue. I also see that you're using macOS 15 and maybe Winit does not support it yet as it's still in beta: have you tried it under 14.6? |
Indeed, the issue is that something is started before |
This is done to avoid order-dependent behavior that you'd otherwise encounter where `EventLoop::new` had to be called at the beginning of `fn main` to ensure that Winit's application was the one being registered as the main application by calling `sharedApplication`. Fixes #3772. This should also make it (more) possible to use multiple versions of Winit in the same application (though that's still untested). Finally, it should allow the user to override NSApplication themselves if they need to do that for some reason.
This is done to avoid order-dependent behavior that you'd otherwise encounter where `EventLoop::new` had to be called at the beginning of `fn main` to ensure that Winit's application was the one being registered as the main application by calling `sharedApplication`. Fixes #3772. This should also make it (more) possible to use multiple versions of Winit in the same application (though that's still untested). Finally, it should allow the user to override `NSApplication` themselves if they need to do that for some reason.
This is done to avoid order-dependent behavior that you'd otherwise encounter where `EventLoop::new` had to be called at the beginning of `fn main` to ensure that Winit's application was the one being registered as the main application by calling `sharedApplication`. Fixes #3772. This should also make it (more) possible to use multiple versions of Winit in the same application (though that's still untested). Finally, it should allow the user to override `NSApplication` themselves if they need to do that for some reason.
This is done to avoid order-dependent behavior that you'd otherwise encounter where `EventLoop::new` had to be called at the beginning of `fn main` to ensure that Winit's application was the one being registered as the main application by calling `sharedApplication`. Fixes #3772. This should also make it (more) possible to use multiple versions of Winit in the same application (though that's still untested). Finally, it should allow the user to override `NSApplication` themselves if they need to do that for some reason.
Description
Background
I built a program combine Qt/Qml and bevy , and I can run it normally on ubuntu system , but when run it on macos, it output a error, and I think this is a platform related problem. So I hope to know how to solve it.
project address
https://github.com/dezbracaty/BevyQml
Information
After running App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems(Update, animate_cube) .run();
It crash and output :
2024-07-02T05:56:27.686954Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 15.0 ", kernel: "24.0.0", cpu: "Apple M1 Pro", core_count: "10", memory: "16.0 GiB" } thread '' panicked at /Users/allen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.30.3/src/platform_impl/macos/event_loop.rs:220:13: winitrequires control over the principal class. You must create the event loop before other parts of your application initialize NSApplication note: run withRUST_BACKTRACE=1 environment variable to display a backtrace fatal runtime error: failed to initiate panic, error 5 [1] 33997 abort /Users/allen/Projects/RustProjects/BevyQml/build/bevyQml/example_qml_minimal
macOS version
Winit version
The text was updated successfully, but these errors were encountered: