Skip to content

Commit

Permalink
Android: potential ANR during onKeyDown/Up
Browse files Browse the repository at this point in the history
SDLActivity may call onNativeKeyDown, while application is quitting
  • Loading branch information
1bsyl committed Jun 16, 2023
1 parent e72935a commit 378e33b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/android/SDL_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,15 +1157,27 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
JNIEnv *env, jclass jcls,
jint keycode)
{
Android_OnKeyDown(keycode);
SDL_LockMutex(Android_ActivityMutex);

if (Android_Window) {
Android_OnKeyDown(keycode);
}

SDL_UnlockMutex(Android_ActivityMutex);
}

/* Keyup */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
JNIEnv *env, jclass jcls,
jint keycode)
{
Android_OnKeyUp(keycode);
SDL_LockMutex(Android_ActivityMutex);

if (Android_Window) {
Android_OnKeyUp(keycode);
}

SDL_UnlockMutex(Android_ActivityMutex);
}

/* Virtual keyboard return key might stop text input */
Expand Down

0 comments on commit 378e33b

Please sign in to comment.