Skip to content
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 macOS w/ Apple M2 #80

Closed
maaku opened this issue Nov 18, 2023 · 6 comments
Closed

panic on macOS w/ Apple M2 #80

maaku opened this issue Nov 18, 2023 · 6 comments

Comments

@maaku
Copy link
Contributor

maaku commented Nov 18, 2023

Steps to reproduce: checkout the template, cd into directory and type cargo run. Panics with:

    Finished dev [optimized + debuginfo] target(s) in 1m 03s
     Running `target/debug/bevy_game`
2023-11-18T20:26:11.043100Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M2 Ultra", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
thread 'main' panicked at src/main.rs:40:54:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2023-11-18T20:26:11.134921Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.1.1 ", kernel: "23.1.0", cpu: "Apple M2 Ultra", core_count: "24", memory: "64.0 GiB" }
Encountered a panic in system `bevy_game::set_window_icon`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

Full backtrace:

    Finished dev [optimized + debuginfo] target(s) in 0.12s
     Running `target/debug/bevy_game`
2023-11-18T20:28:15.565254Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M2 Ultra", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
thread 'main' panicked at src/main.rs:40:54:
called `Option::unwrap()` on a `None` value
stack backtrace:
2023-11-18T20:28:15.649828Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.1.1 ", kernel: "23.1.0", cpu: "Apple M2 Ultra", core_count: "24", memory: "64.0 GiB" }
   0: rust_begin_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:127:5
   3: core::option::Option<T>::unwrap
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/option.rs:935:21
   4: bevy_game::set_window_icon
             at ./src/main.rs:40:19
   5: core::ops::function::FnMut::call_mut
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:166:5
   6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:294:13
   7: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1) .> Out>>::run::call_inner
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/function_system.rs:642:21
   8: <Func as bevy_ecs::system::function_system::SystemParamFunction<fn(F0,F1) .> Out>>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/function_system.rs:645:17
   9: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/function_system.rs:485:19
  10: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}}::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/schedule/executor/multi_threaded.rs:505:26
  11: core::ops::function::FnOnce::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250:5
  12: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:271:9
  13: std::panicking::try::do_call
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  14: std::panicking::try
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  15: std::panic::catch_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  16: bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor::spawn_system_task::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/schedule/executor/multi_threaded.rs:500:23
  17: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:296:9
  18: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:626:42
  19: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:271:9
  20: std::panicking::try::do_call
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  21: std::panicking::try
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  22: std::panic::catch_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  23: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:626:9
  24: async_executor::Executor::spawn::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.6.0/src/lib.rs:151:20
  25: async_task::raw::RawTask<F,T,S,M>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.5.0/src/raw.rs:568:17
  26: async_task::runnable::Runnable<M>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.5.0/src/runnable.rs:784:18
  27: async_executor::Executor::tick::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-executor-1.6.0/src/lib.rs:216:9
  28: bevy_tasks::thread_executor::ThreadExecutorTicker::tick::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/thread_executor.rs:105:39
  29: bevy_tasks::task_pool::TaskPool::execute_scope::{{closure}}::{{closure}}::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:512:45
  30: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::future::future::Future>::poll
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:296:9
  31: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:626:42
  32: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:271:9
  33: std::panicking::try::do_call
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  34: std::panicking::try
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  35: std::panic::catch_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  36: <futures_lite::future::CatchUnwind<F> as core::future::future::Future>::poll
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:626:9
  37: bevy_tasks::task_pool::TaskPool::execute_scope::{{closure}}::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:515:77
  38: <futures_lite::future::Or<F1,F2> as core::future::future::Future>::poll
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:526:33
  39: bevy_tasks::task_pool::TaskPool::execute_scope::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:518:41
  40: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:429:85
  41: futures_lite::future::block_on::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:89:27
  42: std::thread::local::LocalKey<T>::try_with
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/thread/local.rs:270:16
  43: std::thread::local::LocalKey<T>::with
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/thread/local.rs:246:9
  44: futures_lite::future::block_on
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-lite-1.13.0/src/future.rs:79:11
  45: bevy_tasks::task_pool::TaskPool::scope_with_executor_inner
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:383:13
  46: bevy_tasks::task_pool::TaskPool::scope_with_executor::{{closure}}
  47: std::thread::local::LocalKey<T>::try_with
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/thread/local.rs:270:16
  48: std::thread::local::LocalKey<T>::with
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/thread/local.rs:246:9
  49: bevy_tasks::task_pool::TaskPool::scope_with_executor
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_tasks-0.12.0/src/task_pool.rs:316:31
  50: <bevy_ecs::schedule::executor::multi_threaded::MultiThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/schedule/executor/multi_threaded.rs:198:9
  51: bevy_ecs::world::World::try_run_schedule::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2074:55
  52: bevy_ecs::world::World::try_schedule_scope
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2007:21
  53: bevy_ecs::world::World::try_run_schedule
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2074:9
  54: bevy_app::main_schedule::Main::run_main
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.12.0/src/main_schedule.rs:145:27
  55: core::ops::function::FnMut::call_mut
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:166:5
  56: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:294:13
  57: <Func as bevy_ecs::system::exclusive_function_system::ExclusiveSystemParamFunction<fn(F0) .> Out>>::run::call_inner
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/exclusive_function_system.rs:207:21
  58: <Func as bevy_ecs::system::exclusive_function_system::ExclusiveSystemParamFunction<fn(F0) .> Out>>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/exclusive_function_system.rs:210:17
  59: <bevy_ecs::system::exclusive_function_system::ExclusiveFunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/system/exclusive_function_system.rs:107:19
  60: <bevy_ecs::schedule::executor::single_threaded::SingleThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/schedule/executor/single_threaded.rs:92:21
  61: core::ops::function::FnOnce::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250:5
  62: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:271:9
  63: std::panicking::try::do_call
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504:40
  64: std::panicking::try
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468:19
  65: std::panic::catch_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142:14
  66: <bevy_ecs::schedule::executor::single_threaded::SingleThreadedExecutor as bevy_ecs::schedule::executor::SystemExecutor>::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/schedule/executor/single_threaded.rs:91:27
  67: bevy_ecs::world::World::run_schedule::{{closure}}
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2088:51
  68: bevy_ecs::world::World::try_schedule_scope
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2007:21
  69: bevy_ecs::world::World::schedule_scope
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2059:9
  70: bevy_ecs::world::World::run_schedule
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ecs-0.12.0/src/world/mod.rs:2088:9
  71: bevy_app::app::App::update
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.12.0/src/app.rs:265:24
  72: bevy_app::app::App::run
             at /Users/mark/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_app-0.12.0/src/app.rs:317:13
  73: bevy_game::main
             at ./src/main.rs:13:5
  74: core::ops::function::FnOnce::call_once
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_game::set_window_icon`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

It seems the set_window_icon system is getting an empty option value when fetching the primary window handle.

@mikeder
Copy link

mikeder commented Nov 18, 2023

Following, I'm getting the same panic on an M1 while trying to upgrade to Bevy 0.12

mikeder added a commit to mikeder/turtletime that referenced this issue Nov 19, 2023
1. Update Bevy to 0.12
2. Update related deps ( ggrs, bevy_ggrs, matchbox, etc. )
3. Log warning if winit cannot find main window to avoid panic - I don't
understand why this changed see below.
4. Switch to `1.72` toolchain due to Rust compiler regression.

### Winit Panic

Some new issue was introduced with the Bevy 0.12 upgrade, this line
started panicking, so we just log a warning and abort if we can't get
the primary window.


https://github.com/mikeder/turtletime/pull/3/files#diff-42cb6807ad74b3e201c5a7ca98b911c5fa08380e942be6e4ac5807f8377f87fcL83

NiklasEi/bevy_game_template#80

### Compiler Regression

I was unable to compile `bevy-egui-inspector` after updating to Rust to
the 1.74 toolchain, it turns out there was a compiler regression so I've
pinned my toolchain to 1.72 ( there was [another
regression](rust-lang/rust#117545) in 1.73
that sounds nasty enough to avoid for now too )

jakobhellermann/bevy-inspector-egui#163
rust-lang/rust#117976

#### Segmentation Fault

Originally I tried to use the `nightly` toolchain as recommended in the
above `bevy-egui-inspector` issue, but when I did, my game instantly
crashed with a segmentation fault. I tried to use the
[sanitizer](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html)
features to debug it, but the game compiled and ran just fine with the
sanitizer flags. Ultimately I just downgraded to `1.72` and moved on
with my life.
@CestcaVision
Copy link

same issue on my M2 mbp

@CestcaVision
Copy link

I think the bug happens in "set_window_icon" function, if i remove it from systems, compiling success. Maybe this is caused by the incompatibility between new winit version and bevy 0.12. I'm trying to fix it.

@bbarker
Copy link

bbarker commented Dec 2, 2023

I'm getting it on an intel mac, so i believe @CestcaVision is most likely correct but need to look into it more as well

@NiklasEi
Copy link
Owner

NiklasEi commented Dec 3, 2023

Maybe this is caused by the incompatibility between new winit version and bevy 0.12. I'm trying to fix it.

I wouldn't know where the new winter version would come from in you dependency tree. Maybe you can check for duplicate deps?

@NiklasEi
Copy link
Owner

NiklasEi commented Dec 3, 2023

The set_window_icon method no longer unwraps the primary window, which I would consider as a fix for the template. I also checked for duplicate winit dependency and could only find 0.18.7 in my dependency tree.

Not having a window at this point in startup on mac feels like a bevy and/or winit issue. Maybe someone who can reproduce this would like to open an issue there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants