bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.4k stars 3.49k forks source link

Example is not working on MacBook Pro 2023 M2 Max MacOS Sonoma #8950

Open T-Damer opened 1 year ago

T-Damer commented 1 year ago

Bevy version

git checkout latest

Relevant system information

cargo --version
cargo 1.70.0 (ec8a8a0ca 2023-04-25)
SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M2 Max", core_count: "12", memory: "64.0 GiB" }
AdapterInfo { name: "Apple M2 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }

Display settings (using built-in Retina): CleanShot 2023-06-25 at 11 35 51@2x

What you did

Tried setup guide from bevy web-site, it fails to on cargo run --example breakout

What went wrong

It should run an example, but it throws an error, looks like it tries to create too big texture:

cargo run --example breakout
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/examples/breakout`
2023-06-25T08:22:10.737642Z  INFO bevy_render::renderer: AdapterInfo { name: "Apple M2 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
2023-06-25T08:22:11.003041Z  INFO bevy_winit::system: Creating new window "Bevy App" (0v0)
2023-06-25T08:22:11.025435Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "MacOS 14.0 ", kernel: "23.0.0", cpu: "Apple M2 Max", core_count: "12", memory: "64.0 GiB" }
2023-06-25 11:22:11.125 breakout[12073:99431] CAMetalLayer ignoring invalid setDrawableSize width=4294967295.000000 height=4294967295.000000
2023-06-25T08:22:11.125819Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (5)' panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_texture
      note: label = `main_texture_a`
    Dimension X value 4294967295 exceeds the limit of 16384

', /Users/Damer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.15.1/src/backend/direct.rs:3024:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'Compute Task Pool (5)' panicked at 'A system has panicked so the executor cannot continue.: RecvError', crates/bevy_ecs/src/schedule/executor/multi_threaded.rs:194:60
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/Damer/Downloads/bevy/crates/bevy_tasks/src/task_pool.rs:376:49
thread 'Compute Task Pool (0)' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', crates/bevy_render/src/pipelined_rendering.rs:136:45
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/Damer/Downloads/bevy/crates/bevy_tasks/src/task_pool.rs:376:49

Additional info

Related issue - https://github.com/bevyengine/bevy/issues/4869

superdump commented 1 year ago

4294967295 is 2^32 - 1. Odd that that happens on an M2 Max and not an M1 Max, as far as I know. I wonder if it’s a reserved value that should have been checked somewhere (e.g. u32::MAX).

mockersf commented 1 year ago

It's a bug with the beta of next macOS - it works fine with the released macOS

https://github.com/rust-windowing/winit/issues/2876

T-Damer commented 1 year ago

Current workaround is to use BorderlessFullscreen:

use bevy::window::WindowMode;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                mode: WindowMode::BorderlessFullscreen,
                ..default()
            }),
            ..default()
        }))
        .add_startup_system(setup)
        .run();
}
ptxmac commented 1 year ago

It's been fixed upstream in wind, so when the next wind is released it should be fixed by just upgrading the dependency.

I also have my own fix by patching the wing event-handler in bevy: https://github.com/ptxmac/bevy/commit/edfa4e4ec0e0f4cd64da603644b7de58871c9c74

mockersf commented 1 year ago

a new version of Bevy has been published with a patch for this, run cargo update to get Bevy 0.11.3