Repository: tauri-apps/wry (language: rust)

Issue:
Update raw-window-handle dependency to v0.6
**Is your feature request related to a problem? Please describe.**

raw-window-handle crate dependency of this crate is out of date. It is better to update it to the latest because

- some crates require the latest version of raw-window-handle. For example, wgpu v0.19 requires raw-window-handle v0.6 and doesn't work with v0.5
- v0.6 provides safer interface. `WindowHandle` manages lifetime not to make the underlying handle invalid. It is better to make users migrate to the safer interface
- Currently wry has both v0.6 and v0.5 as dev dependency redundantly because winit enables `rwh_06` by default

**Describe the solution you'd like**

Bump up raw-window-handle to v0.6. This means the following breaking changes:

- wry's APIs will require `HasWindowHandle` trait instead of `HasRawWindowHandle` since `HasRawWindowHandle` was deprecated at v0.6
- `wry::raw_window_handle` will re-export v0.6

**Describe alternatives you've considered**

- Support both v0.6 and v0.5 as winit does. This would increase maintenance cost but possible
- Keep v0.5 until v0.6 is mandatory due to some reason

**Additional context**

Nothing.


fix(deps): update rust crate raw-window-handle to 0.6
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [raw-window-handle](https://togithub.com/rust-windowing/raw-window-handle) | dependencies | minor | `0.5` -> `0.6` |

---

### Release Notes

<details>
<summary>rust-windowing/raw-window-handle (raw-window-handle)</summary>

### [`v0.6.0`](https://togithub.com/rust-windowing/raw-window-handle/blob/HEAD/CHANGELOG.md#060-2023-09-30)

[Compare Source](https://togithub.com/rust-windowing/raw-window-handle/compare/v0.5.2...v0.6.0)

-   **Breaking:** Raw pointer handles now use `NonNull` where appropriate, to avoid null pointer dereferences.
-   **Breaking:** Renamed `empty` methods to `new`, and take parameters in most of those, to better match normal Rust semantics.
-   **Breaking:** `HasRaw(Display/Window)Handle::raw_(display/window)_handle` returns a result indicating if fetching the window handle failed ([#&#8203;122](https://togithub.com/rust-windowing/raw-window-handle/issues/122)).
-   **Breaking:** Remove the `Active/ActiveHandle` types from the public API ([#&#8203;126](https://togithub.com/rust-windowing/raw-window-handle/issues/126)).
-   **Breaking:** Remove `AppKitWindowHandle::ns_window` and `UiKitWindowHandle::ui_window` since they can be retrieved from the view ([#&#8203;129](https://togithub.com/rust-windowing/raw-window-handle/issues/129)).
-   **Breaking:** Remove `Copy` derive from `RawWindowHandle` and `WindowHandle` ([#&#8203;140](https://togithub.com/rust-windowing/raw-window-handle/issues/140)).
-   Implement `PartialEq`, `Eq` and `Hash` for `WindowHandle` too. ([#&#8203;128](https://togithub.com/rust-windowing/raw-window-handle/issues/128))
-   Implement the relevant traits for `&mut T where T: <trait>`. ([#&#8203;130](https://togithub.com/rust-windowing/raw-window-handle/issues/130))
-   Add web handles for `wasm-bindgen` v0.2. They are locked behind the `wasm-bindgen-0-2` feature. ([#&#8203;134](https://togithub.com/rust-windowing/raw-window-handle/issues/134))
-   Deprecate the raw window/display handle traits. They will be removed at the next stable release. ([#&#8203;139](https://togithub.com/rust-windowing/raw-window-handle/issues/139))

### [`v0.5.2`](https://togithub.com/rust-windowing/raw-window-handle/blob/HEAD/CHANGELOG.md#052-2023-03-31)

[Compare Source](https://togithub.com/rust-windowing/raw-window-handle/compare/v0.5.1...v0.5.2)

-   Add several types for using raw window handles safely, including `HasWindowHandle`, `WindowHandle`, `HasDisplayHandle`, `DisplayHandle` and `Active` ([#&#8203;110](https://togithub.com/rust-windowing/raw-window-handle/issues/110)).

### [`v0.5.1`](https://togithub.com/rust-windowing/raw-window-handle/blob/HEAD/CHANGELOG.md#051-2023-03-07)

[Compare Source](https://togithub.com/rust-windowing/raw-window-handle/compare/v0.5.0...v0.5.1)

-   Add the `rust-version` field (`1.64`).
-   Implemented `From` for `RawWindowHandle` and `RawDisplayHandle`

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tauri-apps/wry).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6ImRldiJ9-->



Discussion / hints:

Fix patch:
diff --git a/.changes/rwh06.md b/.changes/rwh06.md
new file mode 100644
index 000000000..72eb43372
--- /dev/null
+++ b/.changes/rwh06.md
@@ -0,0 +1,7 @@
+---
+"wry": minor
+---
+
+**Breaking change** Update [raw-window-handle](https://crates.io/crates/raw-window-handle) crate to v0.6.
+- `HasWindowHandle` trait is required for window types instead of `HasRawWindowHandle`.
+- `wry::raw_window_handle` now re-exports v0.6.
diff --git a/Cargo.toml b/Cargo.toml
index ab77ec353..bd7da082a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -58,7 +58,7 @@ serde_json = "1.0"
 thiserror = "1.0"
 url = "2.4"
 http = "0.2"
-raw-window-handle = { version = "0.5", features = [ "std" ] }
+raw-window-handle = { version = "0.6", features = [ "std" ] }
 
 [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies]
 javascriptcore-rs = { version = "=1.1", features = [ "v2_28" ], optional = true }
@@ -75,9 +75,9 @@ windows-implement = "0.52"
 windows-version = "0.1"
 dunce = "1"
 
-  [target."cfg(target_os = \"windows\")".dependencies.windows]
-  version = "0.52"
-  features = [
+[target."cfg(target_os = \"windows\")".dependencies.windows]
+version = "0.52"
+features = [
   "implement",
   "Win32_Foundation",
   "Win32_Graphics_Gdi",
@@ -112,11 +112,11 @@ jni = "0.21"
 ndk = "0.7"
 ndk-sys = "0.4"
 ndk-context = "0.1"
-tao-macros = { version = "0.1.0" }
+tao-macros = "0.1.0"
 
 [dev-dependencies]
 http-range = "0.1.5"
 pollster = "0.3.0"
-tao = { version = "0.24", default-features = false, features = [ "rwh_05" ] }
-wgpu = "0.18.0"
-winit = { version = "0.29", features = [ "rwh_05" ] }
+tao = "0.24"
+wgpu = "0.19.0"
+winit = "0.29"
diff --git a/README.md b/README.md
index d322e0cd2..9f60188ba 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Cross-platform WebView rendering library in Rust that supports all major desktop
 ## Overview
 
 WRY connects the web engine on each platform and provides easy to use and unified interface to render WebView.
-The webview requires a running event loop and a window type that implements `HasRawWindowHandle`,
+The webview requires a running event loop and a window type that implements `HasWindowHandle`,
 or a gtk container widget if you need to support X11 and Wayland.
 You can use a windowing library like `tao` or `winit`.
 
@@ -147,7 +147,7 @@ It is recommended to use [`tao`](https://docs.rs/tao/latest/tao/) crate as it pr
 ```
 
 - `WRY_ANDROID_PACKAGE` which is the reversed domain name of your android project and the app name in snake_case for example: `com.wry.example.wry_app`
-- `WRY_ANDROID_LIBRARY` for example: if your cargo project has a lib name `wry_app`, it will generate `libwry_app.so` so you se this env var to `wry_app`
+- `WRY_ANDROID_LIBRARY` for example: if your cargo project has a lib name `wry_app`, it will generate `libwry_app.so` so you set this env var to `wry_app`
 - `WRY_ANDROID_KOTLIN_FILES_OUT_DIR` for example: `path/to/app/src/main/kotlin/com/wry/example`
 
 ## Partners
diff --git a/examples/wgpu.rs b/examples/wgpu.rs
index 87a266cd0..e33a17e67 100644
--- a/examples/wgpu.rs
+++ b/examples/wgpu.rs
@@ -11,7 +11,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
 
   let instance = wgpu::Instance::default();
 
-  let surface = unsafe { instance.create_surface(&window) }.unwrap();
+  let surface = instance.create_surface(&window).unwrap();
   let adapter = instance
     .request_adapter(&wgpu::RequestAdapterOptions {
       power_preference: wgpu::PowerPreference::default(),
@@ -27,9 +27,10 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
     .request_device(
       &wgpu::DeviceDescriptor {
         label: None,
-        features: wgpu::Features::empty(),
+        required_features: wgpu::Features::empty(),
         // Make sure we use the texture resolution limits from the adapter, so we can support images the size of the swapchain.
-        limits: wgpu::Limits::downlevel_webgl2_defaults().using_resolution(adapter.limits()),
+        required_limits: wgpu::Limits::downlevel_webgl2_defaults()
+          .using_resolution(adapter.limits()),
       },
       None,
     )
@@ -90,6 +91,7 @@ fn fs_main() -> @location(0) vec4<f32> {
     width: size.width,
     height: size.height,
     present_mode: wgpu::PresentMode::Fifo,
+    desired_maximum_frame_latency: 2,
     alpha_mode: swapchain_capabilities.alpha_modes[0],
     view_formats: vec![],
   };
@@ -119,7 +121,7 @@ fn fs_main() -> @location(0) vec4<f32> {
     .unwrap();
 
   event_loop
-    .run(move |event, evl| {
+    .run(|event, evl| {
       evl.set_control_flow(ControlFlow::Poll);
 
       match event {
diff --git a/src/android/mod.rs b/src/android/mod.rs
index 41213bef2..cc2405d4a 100644
--- a/src/android/mod.rs
+++ b/src/android/mod.rs
@@ -19,6 +19,7 @@ use jni::{
 use kuchiki::NodeRef;
 use ndk::looper::{FdEvent, ForeignLooper};
 use once_cell::sync::OnceCell;
+use raw_window_handle::HasWindowHandle;
 use sha2::{Digest, Sha256};
 use std::{
   borrow::Cow,
@@ -124,7 +125,7 @@ pub(crate) struct InnerWebView;
 
 impl InnerWebView {
   pub fn new_as_child(
-    _window: &impl raw_window_handle::HasRawWindowHandle,
+    _window: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     _web_context: Option<&mut WebContext>,
@@ -133,7 +134,7 @@ impl InnerWebView {
   }
 
   pub fn new(
-    _window: &impl raw_window_handle::HasRawWindowHandle,
+    _window: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     _web_context: Option<&mut WebContext>,
diff --git a/src/lib.rs b/src/lib.rs
index 9f91af4ce..1ec0e3231 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,13 +4,13 @@
 
 //! Wry is a Cross-platform WebView rendering library.
 //!
-//! The webview requires a running event loop and a window type that implements [`HasRawWindowHandle`],
+//! The webview requires a running event loop and a window type that implements [`HasWindowHandle`],
 //! or a gtk container widget if you need to support X11 and Wayland.
 //! You can use a windowing library like [`tao`] or [`winit`].
 //!
 //! ## Examples
 //!
-//! This example leverages the [`HasRawWindowHandle`] and supports Windows, macOS, iOS, Android and Linux (X11 Only).
+//! This example leverages the [`HasWindowHandle`] and supports Windows, macOS, iOS, Android and Linux (X11 Only).
 //! See the following example using [`winit`].
 //!
 //! ```no_run
@@ -27,7 +27,7 @@
 //! ```
 //!
 //! If you also want to support Wayland too, then we recommend you use [`WebViewBuilderExtUnix::new_gtk`] on Linux.
-//! See the following example using [`tao`]
+//! See the following example using [`tao`].
 //!
 //! ```no_run
 //! # use wry::WebViewBuilder;
@@ -231,7 +231,7 @@ use android::*;
 pub(crate) mod webkitgtk;
 /// Re-exported [raw-window-handle](https://docs.rs/raw-window-handle/latest/raw_window_handle/) crate.
 pub use raw_window_handle;
-use raw_window_handle::HasRawWindowHandle;
+use raw_window_handle::HasWindowHandle;
 #[cfg(gtk)]
 use webkitgtk::*;
 
@@ -543,7 +543,7 @@ impl Default for WebViewAttributes {
 pub struct WebViewBuilder<'a> {
   pub attrs: WebViewAttributes,
   as_child: bool,
-  window: Option<&'a dyn HasRawWindowHandle>,
+  window: Option<&'a dyn HasWindowHandle>,
   platform_specific: PlatformSpecificWebViewAttributes,
   web_context: Option<&'a mut WebContext>,
   #[cfg(gtk)]
@@ -551,7 +551,7 @@ pub struct WebViewBuilder<'a> {
 }
 
 impl<'a> WebViewBuilder<'a> {
-  /// Create a [`WebViewBuilder`] from a type that implements [`HasRawWindowHandle`].
+  /// Create a [`WebViewBuilder`] from a type that implements [`HasWindowHandle`].
   ///
   /// # Platform-specific:
   ///
@@ -567,7 +567,7 @@ impl<'a> WebViewBuilder<'a> {
   ///
   /// - Panics if the provided handle was not supported or invalid.
   /// - Panics on Linux, if [`gtk::init`] was not called in this thread.
-  pub fn new(window: &'a impl HasRawWindowHandle) -> Self {
+  pub fn new(window: &'a impl HasWindowHandle) -> Self {
     Self {
       attrs: WebViewAttributes::default(),
       window: Some(window),
@@ -580,7 +580,7 @@ impl<'a> WebViewBuilder<'a> {
     }
   }
 
-  /// Create [`WebViewBuilder`] as a child window inside the provided [`HasRawWindowHandle`].
+  /// Create [`WebViewBuilder`] as a child window inside the provided [`HasWindowHandle`].
   ///
   /// ## Platform-specific
   ///
@@ -602,7 +602,7 @@ impl<'a> WebViewBuilder<'a> {
   ///
   /// - Panics if the provided handle was not support or invalid.
   /// - Panics on Linux, if [`gtk::init`] was not called in this thread.
-  pub fn new_as_child(parent: &'a impl HasRawWindowHandle) -> Self {
+  pub fn new_as_child(parent: &'a impl HasWindowHandle) -> Self {
     Self {
       attrs: WebViewAttributes::default(),
       window: Some(parent),
@@ -726,10 +726,12 @@ impl<'a> WebViewBuilder<'a> {
   /// ```no_run
   /// use wry::{WebViewBuilder, raw_window_handle};
   ///
+  /// # use raw_window_handle::{HasWindowHandle, WindowHandle, RawWindowHandle, Win32WindowHandle, HandleError};
   /// # struct T;
-  /// # unsafe impl raw_window_handle::HasRawWindowHandle for T {
-  /// #   fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
-  /// #     raw_window_handle::RawWindowHandle::Win32(raw_window_handle::Win32WindowHandle::empty())
+  /// # impl HasWindowHandle for T {
+  /// #   fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError> {
+  /// #     let handle = RawWindowHandle::Win32(Win32WindowHandle::new(std::num::NonZeroIsize::new(0).unwrap()));
+  /// #     unsafe { Ok(WindowHandle::borrow_raw(handle)) }
   /// #   }
   /// # }
   /// # let window = T;
@@ -1218,7 +1220,7 @@ pub struct WebView {
 }
 
 impl WebView {
-  /// Create a [`WebView`] from from a type that implements [`HasRawWindowHandle`].
+  /// Create a [`WebView`] from from a type that implements [`HasWindowHandle`].
   /// Note that calling this directly loses
   /// abilities to initialize scripts, add ipc handler, and many more before starting WebView. To
   /// benefit from above features, create a [`WebViewBuilder`] instead.
@@ -1237,11 +1239,11 @@ impl WebView {
   ///
   /// - Panics if the provided handle was not supported or invalid.
   /// - Panics on Linux, if [`gtk::init`] was not called in this thread.
-  pub fn new(window: &impl HasRawWindowHandle) -> Result<Self> {
+  pub fn new(window: &impl HasWindowHandle) -> Result<Self> {
     WebViewBuilder::new(window).build()
   }
 
-  /// Create [`WebViewBuilder`] as a child window inside the provided [`HasRawWindowHandle`].
+  /// Create [`WebViewBuilder`] as a child window inside the provided [`HasWindowHandle`].
   ///
   /// ## Platform-specific
   ///
@@ -1263,7 +1265,7 @@ impl WebView {
   ///
   /// - Panics if the provided handle was not support or invalid.
   /// - Panics on Linux, if [`gtk::init`] was not called in this thread.
-  pub fn new_as_child(parent: &impl HasRawWindowHandle) -> Result<Self> {
+  pub fn new_as_child(parent: &impl HasWindowHandle) -> Result<Self> {
     WebViewBuilder::new_as_child(parent).build()
   }
 
diff --git a/src/webkitgtk/mod.rs b/src/webkitgtk/mod.rs
index 69b09328b..ba9b4a1f8 100644
--- a/src/webkitgtk/mod.rs
+++ b/src/webkitgtk/mod.rs
@@ -12,7 +12,7 @@ use gtk::{
   prelude::*,
 };
 use javascriptcore::ValueExt;
-use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
+use raw_window_handle::{HasWindowHandle, RawWindowHandle};
 #[cfg(any(debug_assertions, feature = "devtools"))]
 use std::sync::atomic::{AtomicBool, Ordering};
 use std::sync::{Arc, Mutex};
@@ -75,7 +75,7 @@ impl Drop for InnerWebView {
 }
 
 impl InnerWebView {
-  pub fn new<W: HasRawWindowHandle>(
+  pub fn new<W: HasWindowHandle>(
     window: &W,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
@@ -84,7 +84,7 @@ impl InnerWebView {
     Self::new_x11(window, attributes, pl_attrs, web_context, false)
   }
 
-  pub fn new_as_child<W: HasRawWindowHandle>(
+  pub fn new_as_child<W: HasWindowHandle>(
     parent: &W,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
@@ -93,7 +93,7 @@ impl InnerWebView {
     Self::new_x11(parent, attributes, pl_attrs, web_context, true)
   }
 
-  fn new_x11<W: HasRawWindowHandle>(
+  fn new_x11<W: HasWindowHandle>(
     window: &W,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
@@ -102,7 +102,7 @@ impl InnerWebView {
   ) -> Result<Self> {
     let xlib = Xlib::open()?;
 
-    let window_handle = match window.raw_window_handle() {
+    let window_handle = match window.window_handle()?.as_raw() {
       RawWindowHandle::Xlib(w) => w.window,
       _ => return Err(Error::UnsupportedWindowHandle),
     };
diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs
index 1de48baec..1e68b82a6 100644
--- a/src/webview2/mod.rs
+++ b/src/webview2/mod.rs
@@ -11,7 +11,7 @@ use std::{
 
 use http::{Request, Response as HttpResponse, StatusCode};
 use once_cell::sync::Lazy;
-use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
+use raw_window_handle::{HasWindowHandle, RawWindowHandle};
 use url::Url;
 use webview2_com::{Microsoft::Web::WebView2::Win32::*, *};
 use windows::{
@@ -74,26 +74,26 @@ impl Drop for InnerWebView {
 
 impl InnerWebView {
   pub fn new(
-    window: &impl HasRawWindowHandle,
+    window: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     web_context: Option<&mut WebContext>,
   ) -> Result<Self> {
-    let window = match window.raw_window_handle() {
-      RawWindowHandle::Win32(window) => window.hwnd as _,
+    let window = match window.window_handle()?.as_raw() {
+      RawWindowHandle::Win32(window) => window.hwnd.get() as _,
       _ => return Err(Error::UnsupportedWindowHandle),
     };
     Self::new_hwnd(HWND(window), attributes, pl_attrs, web_context)
   }
 
   pub fn new_as_child(
-    parent: &impl HasRawWindowHandle,
+    parent: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     web_context: Option<&mut WebContext>,
   ) -> Result<Self> {
-    let parent = match parent.raw_window_handle() {
-      RawWindowHandle::Win32(parent) => parent.hwnd as _,
+    let parent = match parent.window_handle()?.as_raw() {
+      RawWindowHandle::Win32(parent) => parent.hwnd.get() as _,
       _ => return Err(Error::UnsupportedWindowHandle),
     };
 
diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs
index 9be5703cd..8301cbd83 100644
--- a/src/wkwebview/mod.rs
+++ b/src/wkwebview/mod.rs
@@ -17,7 +17,7 @@ use cocoa::{
   base::{id, nil, NO, YES},
   foundation::{NSDictionary, NSFastEnumeration, NSInteger},
 };
-use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
+use raw_window_handle::{HasWindowHandle, RawWindowHandle};
 use url::Url;
 
 use std::{
@@ -92,16 +92,16 @@ pub(crate) struct InnerWebView {
 
 impl InnerWebView {
   pub fn new(
-    window: &impl HasRawWindowHandle,
+    window: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     _web_context: Option<&mut WebContext>,
   ) -> Result<Self> {
-    let ns_view = match window.raw_window_handle() {
+    let ns_view = match window.window_handle()?.as_raw() {
       #[cfg(target_os = "macos")]
-      RawWindowHandle::AppKit(w) => w.ns_view,
+      RawWindowHandle::AppKit(w) => w.ns_view.as_ptr(),
       #[cfg(target_os = "ios")]
-      RawWindowHandle::UiKit(w) => w.ui_view,
+      RawWindowHandle::UiKit(w) => w.ui_view.as_ptr(),
       _ => return Err(Error::UnsupportedWindowHandle),
     };
 
@@ -109,16 +109,16 @@ impl InnerWebView {
   }
 
   pub fn new_as_child(
-    window: &impl HasRawWindowHandle,
+    window: &impl HasWindowHandle,
     attributes: WebViewAttributes,
     pl_attrs: super::PlatformSpecificWebViewAttributes,
     _web_context: Option<&mut WebContext>,
   ) -> Result<Self> {
-    let ns_view = match window.raw_window_handle() {
+    let ns_view = match window.window_handle()?.as_raw() {
       #[cfg(target_os = "macos")]
-      RawWindowHandle::AppKit(w) => w.ns_view,
+      RawWindowHandle::AppKit(w) => w.ns_view.as_ptr(),
       #[cfg(target_os = "ios")]
-      RawWindowHandle::UiKit(w) => w.ui_view,
+      RawWindowHandle::UiKit(w) => w.ui_view.as_ptr(),
       _ => return Err(Error::UnsupportedWindowHandle),
     };
 


Test patch: