-
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
Android window handle invalidation #84
Comments
Has there been any investigation into ndk-glue to see if it's actually doing things properly? For example, the window pointer is pulled out of a an RwLock and I didn't see any usage of ANativeWindow_acquire or ANativeWindow_release. I don't know much about how andriod windows work but it looks a little suspicious on first glance. |
@aloucks Thanks for the reminder, I almost forgot that I still had rust-mobile/ndk#207 sitting around locally. Fwiw I don't think https://developer.android.com/ndk/reference/group/a-native-window#anativewindow_acquire
In other words, it's better to look at when we zero out that |
If we call |
@aloucks I still want to test that before merging rust-mobile/ndk#207. As far as I understand Android gives us a window in If we however acquire it, I don't know what happens after Android "says" it's going to be destroyed since the window seems/should be useless after that point? EDIT: We should not access it at all after returning from that callback - no mention of
Likewise, what'd happen if we call All things to test out :) EDIT: In hindsight these functions seem more relevant when creating an |
Turns out I tested Take these with a grain of salt as they are not specified in the reference (as quoted above: "You MUST ensure that you do not touch the window object after returning from this function") and might differ between Android versions and (:vomiting_face: please forbid) vendor modifications.
|
Borrowed window handles should handle this properly, see #111 |
I think this issue might be a bit misleading/out-of-date and perhaps at the time it was filed it may have been a reflection of the synchronization issues that used to exist with Here's a recent summary of how I think this looks on Android: #111 (comment) As far as I know there isn't a safety issue - it's just that on Android applications need to be aware that they have to recreate their graphics API surfaces when they resume (E.g. after So long as we hold a reference to the |
Window handles on Android can be invalidated between a pair of "suspend" and "resume" events. This makes it difficult to safely use window handles without asking end users to wire up the missing event handling. Thus, an API naïvely accepting a
T: HasRawWindowHandle
is inherently unsafe on Android.The text was updated successfully, but these errors were encountered: