From 32ca64e3a30f2ab67654ed4af94ac69bb2e416fc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 29 Jul 2013 15:13:02 +0200 Subject: [PATCH] Attempt to solve Android ANR issues - found this - https://developer.nvidia.com/content/nativeactivity-input-crashes-and-anrs-simple-fix-dangerous-bug --- android/native/jni/input_android.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 6ac23ba591..193dae7530 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -1585,20 +1585,21 @@ static void android_input_poll(void *data) // Read all pending events. while (AInputQueue_hasEvents(android_app->inputQueue)) { - if (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0) + int processed = 0; + while (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0) { bool long_msg_enable = false; int32_t handled = 1; int action = 0; char msg[128]; int source, id, keycode, type_event, state_id; - //int predispatched; + int predispatched; msg[0] = 0; - //predispatched =AInputQueue_preDispatchEvent(android_app->inputQueue,event); + predispatched =AInputQueue_preDispatchEvent(android_app->inputQueue,event); - //if (predispatched) - //continue; + if (predispatched) + continue; source = AInputEvent_getSource(event); id = AInputEvent_getDeviceId(event); @@ -1747,7 +1748,10 @@ static void android_input_poll(void *data) msg_queue_push(g_extern.msg_queue, msg, 0, long_msg_enable ? 180 : 30); AInputQueue_finishEvent(android_app->inputQueue, event, handled); + processed = 1; } + if (processed == 0) + RARCH_WARN("Failure reading next input event: %s\n", strerror(errno)); } } else if (ident == LOOPER_ID_MAIN)