From 20ed3e0e765405ee334a44ce3c49c72bd29ab753 Mon Sep 17 00:00:00 2001 From: Marco Buono Date: Wed, 27 Sep 2023 19:41:16 -0300 Subject: [PATCH] =?UTF-8?q?macOS=20Sonoma=20(14.0)=20/=20Xcode=2015.0=20?= =?UTF-8?q?=E2=80=94=20Compatibility=20Fixes=20+=20Docs=20(#9905)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Improve compatibility with macOS Sonoma and Xcode 15.0. ## Solution - Adds the workaround by @ptxmac to ignore the invalid window sizes provided by `winit` on macOS 14.0 - This still provides a slightly wrong content size when resizing (it fails to account for the window title bar, so some content gets clipped at the bottom) but it's _much better_ than crashing. - Adds docs on how to work around the `bindgen` bug on Xcode 15.0. ## Related Issues: - https://github.com/RustAudio/coreaudio-sys/issues/85 - https://github.com/rust-windowing/winit/issues/2876 --- ## Changelog - Added a workaround for a `winit`-related crash under macOS Sonoma (14.0) --------- Co-authored-by: Peter Kristensen --- crates/bevy_winit/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs index a13c158709bfe..3947b5020a867 100644 --- a/crates/bevy_winit/src/lib.rs +++ b/crates/bevy_winit/src/lib.rs @@ -441,6 +441,14 @@ pub fn winit_runner(mut app: App) { match event { WindowEvent::Resized(size) => { + // TODO: Remove this once we upgrade winit to a version with the fix + #[cfg(target_os = "macos")] + if size.width == u32::MAX || size.height == u32::MAX { + // HACK to fix a bug on Macos 14 + // https://github.com/rust-windowing/winit/issues/2876 + return; + } + window .resolution .set_physical_resolution(size.width, size.height);