diff --git a/CHANGELOG.md b/CHANGELOG.md index ef4548fa31..e3d17fd52d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,14 @@ Bottom level categories: ## Unreleased +## 23.1.0 (2024-11-??) + +### Bug fixes + +#### Metal + +- Fix surface creation crashing on iOS. By @mockersf in [#6535](https://github.com/gfx-rs/wgpu/pull/6535) + ## 23.0.0 (2024-10-25) ### Themes of this release diff --git a/wgpu-hal/src/metal/surface.rs b/wgpu-hal/src/metal/surface.rs index 668b602474..b35c73c910 100644 --- a/wgpu-hal/src/metal/surface.rs +++ b/wgpu-hal/src/metal/surface.rs @@ -1,6 +1,5 @@ #![allow(clippy::let_unit_value)] // `let () =` being used to constrain result type -use std::ffi::c_uint; use std::mem::ManuallyDrop; use std::ptr::NonNull; use std::sync::Once; @@ -207,23 +206,26 @@ impl super::Surface { let new_layer: *mut Object = msg_send![class!(CAMetalLayer), new]; let () = msg_send![root_layer, addSublayer: new_layer]; - // Automatically resize the sublayer's frame to match the - // superlayer's bounds. - // - // Note that there is a somewhat hidden design decision in this: - // We define the `width` and `height` in `configure` to control - // the `drawableSize` of the layer, while `bounds` and `frame` are - // outside of the user's direct control - instead, though, they - // can control the size of the view (or root layer), and get the - // desired effect that way. - // - // We _could_ also let `configure` set the `bounds` size, however - // that would be inconsistent with using the root layer directly - // (as we may do, see above). - let width_sizable = 1 << 1; // kCALayerWidthSizable - let height_sizable = 1 << 4; // kCALayerHeightSizable - let mask: c_uint = width_sizable | height_sizable; - let () = msg_send![new_layer, setAutoresizingMask: mask]; + #[cfg(target_os = "macos")] + { + // Automatically resize the sublayer's frame to match the + // superlayer's bounds. + // + // Note that there is a somewhat hidden design decision in this: + // We define the `width` and `height` in `configure` to control + // the `drawableSize` of the layer, while `bounds` and `frame` are + // outside of the user's direct control - instead, though, they + // can control the size of the view (or root layer), and get the + // desired effect that way. + // + // We _could_ also let `configure` set the `bounds` size, however + // that would be inconsistent with using the root layer directly + // (as we may do, see above). + let width_sizable = 1 << 1; // kCALayerWidthSizable + let height_sizable = 1 << 4; // kCALayerHeightSizable + let mask: std::ffi::c_uint = width_sizable | height_sizable; + let () = msg_send![new_layer, setAutoresizingMask: mask]; + } // Specify the relative size that the auto resizing mask above // will keep (i.e. tell it to fill out its superlayer).