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)
### 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)

View File

@ -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,6 +206,8 @@ impl super::Surface {
let new_layer: *mut Object = msg_send![class!(CAMetalLayer), new];
let () = msg_send![root_layer, addSublayer: new_layer];
#[cfg(target_os = "macos")]
{
// Automatically resize the sublayer's frame to match the
// superlayer's bounds.
//
@ -222,8 +223,9 @@ impl super::Surface {
// (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 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).