Replies: 3 comments 10 replies
-
See android/ndk-samples#1008 for an example of the fix. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Is it "not safe" just because |
Beta Was this translation helpful? Give feedback.
10 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The OS has marked
ALooper_pollAll
as removed. The definition is still present in libandroid, so existing apps will continue to function (though probably with the bug described below), but apps building with NDK r27 or newer will not be able to call that function.To explain here since the explanation isn't in the docs yet:
ALooper_pollAll
will not wake in response toALooper_wake
if it also handles another event at the same time. The exact circumstances where calls toALooper_pollAll
is or isn't a bug aren't the kind of thing we can write a perfectly accurate diagnostic for, but it's unlikely that any non-trivial application that usespollAll
is free of this bug. As such, the API was marked removed, since there is a safe replacement.The core of the problem is the nuance in https://developer.android.com/ndk/reference/group/looper#alooper_pollonce:
ALOOPER_POLL_WAKE
is only returned whenALooper_wake
is the only event handled.ALooper_pollAll
usesALooper_pollOnce
internally, and only returns when it receivesALOOPER_POLL_WAKE
, which is not necessarily returned whenALooper_wake
is called.The fix, aiui, is to call
ALooper_pollOnce
, and break out of your loop for any of the results, not justALOOPER_POLL_WAKE
, since any other return value might also implyALOOPER_POLL_WAKE
.Beta Was this translation helpful? Give feedback.
All reactions