-
Notifications
You must be signed in to change notification settings - Fork 51
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
Change the "Active" struct to be sound #116
Conversation
65a9d76
to
2397bc0
Compare
Just having a look on the bus, things seem pretty good. I'd like for there to be more documentation, perhaps at the module level, about how a person writing a system lib should approach things (eg: winit/sdl2 folks), and how a person writing a graphics lib (eg: wgpu/ash folks) should approach things. I think the ideal is that people other than those two groups shouldn't have to look too carefully in here? Just pass a winit thing to a wgpu thing? So the system lib audience and graphics lib audience seem like our main users. I wouldn't say that this is a blocking concern, but "good docs" is the second most important part of a crate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna approve this now, and leave it up to you notgull on if you want to add more usage docs now or not. The alternative is we just merge it and we can always add more docs as a patch if people end up having specific questions.
Sounds good! I've added some more documentation, with some specifically targeting |
I think for the doc links to work out approximately correctly you'll have to put in links to |
heya, just continuing to follow the trail of recent changes here... Just because I see that Glutin was used to smoke test this change above - does that mean that you were seeing a problem with Glutin on Android before? As far as I know, this Glutin example had been working for me on Android: https://github.com/rust-mobile/rust-android-examples/tree/main/na-winit-glutin (working across suspend / resume and cross-platform too) The main consideration that was required for Android apps was that they need to re-create render surfaces when they resume. One portable way of handling this is that apps can drop their surface state when they Suspend (only ever happens on Android / iOS) and they can lazily create the render surfaces when they Resume (in Winit, all platforms get a Resume event). I have to admit I'm currently a bit daunted by the new I've had an initial look at the draft changes to use this in Glutin but I don't know that I entirely followed how the active status is handled (I just noticed that when let raw_window_handle =
window.as_ref().map(|window| window.window_handle()).transpose().expect("Inactive"); and I saw that various places (like My current understanding is that if you want to write an application for Android based on this change then it's still your responsibility to only try and create a surface while 'active' and this doesn't try to make APIs such as Glutin automatically poll the active status and lazily [re]create surfaces (that's what I originally guessed this change might be aiming for). If that's the case then I'm not currently sure if this change was required if there wasn't really a safety issue with accessing inactive As far as I know an Again, sorry for being late with asking questions here, since this has already been merged, but it feels like quite a significant change which I think is likely to affect my usage and I'm hoping to get a clearer understanding and also double check what's required here. |
No, it was mostly just to verify that nothing serious had been broken by my changes. I would've used
I agree, this is definitely the "monster in the closet" for the current implementation; it introduces a potential deadlock that wasn't there before (i.e. someone is holding a window handle while waiting for events, while the event loop is blocked waiting for that user to drop a window handle). I think that the docs explicitly call out the fact that you shouldn't use a native window handle after
|
@notgull let me know if you need a Aside that would also be nice to validate the |
The previous implementation is unsound in several cases. This PR ensures that window handles don't outlive the application.
Draft until I can verify that it actually works. Supersedes #114