mirror of
https://github.com/rust-mobile/android-activity.git
synced 2026-07-04 05:47:26 +00:00
Assert that the thread Looper matches the main one
This commit is contained in:
committed by
Robert Bragg
parent
a97cf1ceae
commit
9e8c85c647
@@ -295,6 +295,11 @@ impl AndroidAppInner {
|
||||
|
||||
unsafe {
|
||||
let native_app = &self.native_app;
|
||||
assert_eq!(
|
||||
ndk_sys::ALooper_forThread(),
|
||||
(*native_app.as_ptr()).looper,
|
||||
"Application tried to poll events from non-main thread"
|
||||
);
|
||||
|
||||
let mut fd: i32 = 0;
|
||||
let mut events: i32 = 0;
|
||||
@@ -590,7 +595,7 @@ impl AndroidAppInner {
|
||||
let mut guard = self.input_receiver.lock().unwrap();
|
||||
|
||||
// Make sure we don't hand out more than one receiver at a time because
|
||||
// turning the reciever into an interator will perform a swap_buffers
|
||||
// turning the receiver into an iterator will perform a swap_buffers
|
||||
// for the buffered input events which shouldn't happen while we're in
|
||||
// the middle of iterating events
|
||||
if let Some(receiver) = &*guard {
|
||||
|
||||
@@ -201,8 +201,9 @@ impl AndroidAppInner {
|
||||
};
|
||||
|
||||
trace!("Calling ALooper_pollAll, timeout = {timeout_milliseconds}");
|
||||
assert!(
|
||||
!ndk_sys::ALooper_forThread().is_null(),
|
||||
assert_eq!(
|
||||
ndk_sys::ALooper_forThread(),
|
||||
self.looper.ptr,
|
||||
"Application tried to poll events from non-main thread"
|
||||
);
|
||||
let id = ndk_sys::ALooper_pollAll(
|
||||
|
||||
Reference in New Issue
Block a user