You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ndk-glue: Don't return from onCreate until LOOPER is created
Android only performs additional initialization like providing an input
queue through `onInputQueueCreated` after the main initialization
function (`ANativeActivity_onCreate`) returns. In some cases it is
possible that the main thread spawned here hasn't attached a looper to
its thread and assigned it to the accompanying `LOOPER` static variable
yet, resulting in a `None` unwrap when Android provides us with an input
queue.
This race condition is simply solved by not returning from `fn init()`
(`ANativeActivity_onCreate`) until the thread has finished its setup,
through wrapping `LOOPER` in a `Mutex` and using a condition variable to
signal when it is ready.
This condition is intentionally not exposed to `on_input_queue_created`
may we ever have a cleanup procedure that sets `LOOPER` back to `None`;
any call to `onInputQueueCreated` in that state would be an error and
should not block indefinitely. The `LOOPER` should simply be ready by
the time `fn init()` returns.
Fixesrust-mobile#116
0 commit comments