Recently, I played a bit with Android in combination with winit/Vulkan/wgpu and there are some topics which should be addressed imo:
raw-window-handle docs:
The exact handles returned by raw_window_handle must remain consistent between multiple calls to raw_window_handle, and must be valid for at least the lifetime of the HasRawWindowHandle implementer.
This constraint is in particular hard to uphold for winit as the window handle is only available between certain events in the event loop. As far as I know the ANativeWindow may change ov ertime (Suspend-Resumed cycles).
- Change the type of
a_native_window from *mut _ to Option<NonNull<_>> or it should be explictly annotated that it may be null. Right now this is not clear, some graphic libraries assume it's always a valid handle. On the other hand, winit currently panicks when requesting the RawWindowHandle as it shouldn't return a nullptr, which basically shifts the issue to the client to uphold the requirement of only requesting the handle if it safe to do so. This makes it actually quite hard to write portable implementations for anything Vulkan based (extensions query and surface support via RawWindowHandle). Using the Option<NonNull<_>> would make it safe for libraries consuming the handle as well as window libraries to say that a handle might not be available right now.
Recently, I played a bit with Android in combination with winit/Vulkan/wgpu and there are some topics which should be addressed imo:
raw-window-handledocs:This constraint is in particular hard to uphold for winit as the window handle is only available between certain events in the event loop. As far as I know the ANativeWindow may change ov ertime (Suspend-Resumed cycles).
a_native_windowfrom*mut _toOption<NonNull<_>>or it should be explictly annotated that it may benull. Right now this is not clear, some graphic libraries assume it's always a valid handle. On the other hand, winit currently panicks when requesting the RawWindowHandle as it shouldn't return a nullptr, which basically shifts the issue to the client to uphold the requirement of only requesting the handle if it safe to do so. This makes it actually quite hard to write portable implementations for anything Vulkan based (extensions query and surface support via RawWindowHandle). Using theOption<NonNull<_>>would make it safe for libraries consuming the handle as well as window libraries to say that a handle might not be available right now.