Fix iOS crash: don't set autoresizing mask (#6535)

This commit is contained in:
François Mockers 2024-11-15 09:18:11 +01:00 committed by GitHub
parent 278620be26
commit 4681f4ffba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 18 deletions

View File

@ -139,6 +139,10 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
- Fix surface capabilities being advertised when its query failed. By @wumpf in [#6510](https://github.com/gfx-rs/wgpu/pull/6510) - Fix surface capabilities being advertised when its query failed. By @wumpf in [#6510](https://github.com/gfx-rs/wgpu/pull/6510)
### 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) ## 23.0.0 (2024-10-25)

View File

@ -1,6 +1,5 @@
#![allow(clippy::let_unit_value)] // `let () =` being used to constrain result type #![allow(clippy::let_unit_value)] // `let () =` being used to constrain result type
use std::ffi::c_uint;
use std::mem::ManuallyDrop; use std::mem::ManuallyDrop;
use std::ptr::NonNull; use std::ptr::NonNull;
use std::sync::Once; use std::sync::Once;
@ -207,23 +206,26 @@ impl super::Surface {
let new_layer: *mut Object = msg_send![class!(CAMetalLayer), new]; let new_layer: *mut Object = msg_send![class!(CAMetalLayer), new];
let () = msg_send![root_layer, addSublayer: new_layer]; let () = msg_send![root_layer, addSublayer: new_layer];
// Automatically resize the sublayer's frame to match the #[cfg(target_os = "macos")]
// superlayer's bounds. {
// // Automatically resize the sublayer's frame to match the
// Note that there is a somewhat hidden design decision in this: // superlayer's bounds.
// We define the `width` and `height` in `configure` to control //
// the `drawableSize` of the layer, while `bounds` and `frame` are // Note that there is a somewhat hidden design decision in this:
// outside of the user's direct control - instead, though, they // We define the `width` and `height` in `configure` to control
// can control the size of the view (or root layer), and get the // the `drawableSize` of the layer, while `bounds` and `frame` are
// desired effect that way. // outside of the user's direct control - instead, though, they
// // can control the size of the view (or root layer), and get the
// We _could_ also let `configure` set the `bounds` size, however // desired effect that way.
// that would be inconsistent with using the root layer directly //
// (as we may do, see above). // We _could_ also let `configure` set the `bounds` size, however
let width_sizable = 1 << 1; // kCALayerWidthSizable // that would be inconsistent with using the root layer directly
let height_sizable = 1 << 4; // kCALayerHeightSizable // (as we may do, see above).
let mask: c_uint = width_sizable | height_sizable; let width_sizable = 1 << 1; // kCALayerWidthSizable
let () = msg_send![new_layer, setAutoresizingMask: mask]; 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 // Specify the relative size that the auto resizing mask above
// will keep (i.e. tell it to fill out its superlayer). // will keep (i.e. tell it to fill out its superlayer).