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

A safe API wrapper interface #80

Closed
rbermani opened this issue Mar 16, 2023 · 4 comments
Closed

A safe API wrapper interface #80

rbermani opened this issue Mar 16, 2023 · 4 comments

Comments

@rbermani
Copy link

Has there been any consideration as to wrapping the unsafe bits of the user facing API into a safe abstraction?

@ids1024
Copy link
Member

ids1024 commented Mar 16, 2023

As long as it takes a RawWindowHandle it has to be unsafe. The exact implications dependent on platform, but that contains pointers on some platforms for instance, so it can trivially cause use-after-free if the RawWindowHandle isn't valid anymore, etc.

@notgull Was working on a safe wrapper to raw-window-handle recently: https://github.com/notgull/window-handle

If that approach can reliably work and be safe, it would be good to see it integrated into winit, softbuffer, glutin, wgpu, or anything else using raw-window-handle.

@rbermani
Copy link
Author

Thanks. I'll keep an eye on @notgull's project. I have been using the rust pixels crate in lieu of softbuffer for an application that doesn't actually require GPU acceleration. It appears to be hiding the RawWindowHandle inside the implementation.

@Jules-Bertholet
Copy link

raw-window-handle 0.5.2 now has a safe API based on notgull's work, maybe this issue could be revisited?

@notgull
Copy link
Member

notgull commented Jul 13, 2023

raw-window-handle 0.5.2 now has a safe API based on notgull's work, maybe this issue could be revisited?

I've opened a PR (#132) in anticipation of the new raw-window-handle breaking changes in the upcoming v0.6 (rust-windowing/raw-window-handle#125).

I'd like to file equivalent draft PRs for glutin and wgpu before I release rwh v0.6. There's also this issue which needs to be resolved as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants