report stack of lock owner to crashlytics when can't get it

I'm seeing something permanently lock a game so it can't be opened. So
add code to report the stack of the owner to Crashlytics when opening
fails 3 times in a row. It's stubbed out for non-debug builds.
This commit is contained in:
Eric House 2019-02-10 20:02:43 -08:00
parent babca4a696
commit 25509c729a
5 changed files with 32 additions and 1 deletions

View file

@ -70,6 +70,7 @@ android {
resValue "string", "invite_prefix", "/and/"
buildConfigField "int[]", "SMS_BANNED_EXPL", "null"
buildConfigField "boolean", "UDP_ENABLED", "true"
buildConfigField "boolean", "REPORT_LOCKS", "false"
}
xw4 {
@ -104,6 +105,7 @@ android {
buildConfigField "boolean", "WIDIR_ENABLED", "true"
buildConfigField "boolean", "RELAYINVITE_SUPPORTED", "true"
buildConfigField "String", "VARIANT_NAME", "\"Dev/Debug\""
buildConfigField "boolean", "REPORT_LOCKS", "true"
}
xw4dNoSMS {

View file

@ -510,6 +510,7 @@ public class BoardDelegate extends DelegateBase
m_activity = delegator.getActivity();
}
private static int s_noLockCount = 0; // supports a quick debugging hack
protected void init( Bundle savedInstanceState )
{
m_isFirstLaunch = null == savedInstanceState;
@ -544,7 +545,13 @@ public class BoardDelegate extends DelegateBase
public void gotLock( GameLock lock ) {
if ( null == lock ) {
finish();
if ( BuildConfig.REPORT_LOCKS && ++s_noLockCount == 3 ) {
String msg = "BoardDelegate unable to get lock; holder stack: "
+ GameLock.getHolderStack( m_rowid );
CrashTrack.logAndSend( msg );
}
} else {
s_noLockCount = 0;
m_jniThreadRef = JNIThread.getRetained( lock );
// see http://stackoverflow.com/questions/680180/where-to-stop- \

View file

@ -64,7 +64,6 @@ public class GameLock implements AutoCloseable, Serializable {
Owner()
{
mThread = Thread.currentThread();
// mTrace = mThread.getStackTrace();
mTrace = android.util.Log.getStackTraceString(new Exception());
}
@ -361,6 +360,13 @@ public class GameLock implements AutoCloseable, Serializable {
} ).start();
}
public static String getHolderStack( long rowid )
{
GameLockState state = getFor( rowid );
Owner owner = state.mOwners.peek();
return owner.mTrace;
}
// used only for asserts
public boolean canWrite()
{

View file

@ -24,4 +24,5 @@ import android.content.Context;
public class CrashTrack {
public static void init( Context context ) {} // does nothing here
public static void logAndSend( String msg ) {}
}

View file

@ -60,4 +60,19 @@ public class CrashTrack {
}
}
}
public static void logAndSend( String msg )
{
Crashlytics.log( msg );
new Thread( new Runnable() {
@Override
public void run() {
String foo = null;
try {
Thread.sleep( 5000 );
throw new RuntimeException( "crash generator" );
} catch ( InterruptedException ex ) {}
}
} ).start();
}
}