From 9f0324f8ae99030747446230308f1559714cb111 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 14 Jan 2020 08:32:30 -0800 Subject: [PATCH] remove assert firing in field There must be some race condition. Better than crashing is to fail to dispose a game's memory, which hopefully will be the effect here. I don't understand how this happens to can't test. --- xwords4/android/app/src/main/assets/changes.html | 1 + .../src/main/java/org/eehouse/android/xw4/jni/XwJNI.java | 9 ++++++--- xwords4/android/jni/xwjni.c | 2 -- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xwords4/android/app/src/main/assets/changes.html b/xwords4/android/app/src/main/assets/changes.html index 94f23312d..7e850ae69 100644 --- a/xwords4/android/app/src/main/assets/changes.html +++ b/xwords4/android/app/src/main/assets/changes.html @@ -28,6 +28,7 @@
  • Fix board sometimes being blank after chat window dismissed
  • Don't show NFC stats if it's not been used
  • Include new Catalan and Spanish translations (from Weblate)
  • +
  • Fix crash reported via Google Play Store
  • (The full changelog diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java index 2e2e9422b..47bb6675c 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java @@ -73,10 +73,13 @@ public class XwJNI { // getClass().getName(), this, m_rowid, m_refCount ); if ( 0 == m_refCount ) { if ( 0 != m_ptrGame ) { - if ( !haveEnv( getJNI().m_ptrGlobals ) ) { - Assert.fail(); + if ( haveEnv( getJNI().m_ptrGlobals ) ) { + game_dispose( this ); // will crash if haveEnv fails + } else { + Log.d( TAG, "release(): no ENV!!! (this=%H, rowid=%d)", + this, m_rowid ); + Assert.failDbg(); // seen on Play Store console } - game_dispose( this ); // will crash if haveEnv fails m_ptrGame = 0; } } else { diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index 337842c69..473895808 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -910,7 +910,6 @@ struct _JNIState { XWGame game; JNIGlobalState* globalJNI; AndGameGlobals globals; - // pthread_mutex_t msgMutex; XP_U16 curSaveCount; XP_U16 lastSavedSize; #ifdef DEBUG @@ -1029,7 +1028,6 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1dispose vtmgr_destroy( MPPARM(mpool) globals->vtMgr ); MAP_REMOVE( &state->globalJNI->ti, env ); - /* pthread_mutex_destroy( &state->msgMutex ); */ XP_FREE( mpool, state ); } /* game_dispose */