Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return an Option from Window::raw_window_handle() + add WindowConfigured event #2769

Open
rib opened this issue Apr 13, 2023 · 2 comments
Open
Labels
S - api Design and usability

Comments

@rib
Copy link
Contributor

rib commented Apr 13, 2023

It's not great that the Android backend will simply panic if Window::raw_window_handle() is called while the app is suspended and it would be nicer if the API instead returned an Option to convey when no handle is currently available.

Winit could then promise/guarantee that a handle will always be available for RedrawRequested events and it would be platform-dependent whether a handle is also be accessible outside of redraw events.

This could potentially also benefit the Wayland backend which has to wait for an ack from the compositor before a raw handle should be accessible for creating graphics API surfaces after creating a new Window. (Right now the wayland backend has to synchronously wait for a compositor round trip in Window::new and this is also having a pretty significant impact on the backend's internal design because it needs to have a buffering abstraction to avoid a reentrancy problem)

To help give applications a natural place to initialize graphics API surfaces (i.e. egl,vulkan/wgpu surfaces) for new windows, then we could also add a WindowConfigured or WindowReady event that all backends will be guaranteed to dispatch once for any new window at the earliest point at which a raw-window-handle is accessible.

@kchibisov kchibisov added the S - api Design and usability label Apr 13, 2023
@kchibisov
Copy link
Member

See rust-windowing/raw-window-handle#104

In general, I think we should have some sort of indication.

@rib
Copy link
Contributor Author

rib commented Apr 13, 2023

Thanks for the pointer

@kchibisov kchibisov added this to the Version 0.31.0 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S - api Design and usability
Development

No branches or pull requests

2 participants