-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Android) Introduce ANR monitor to produce warn-logs
- Loading branch information
Showing
13 changed files
with
255 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
detox/android/detox/src/main/java/com/wix/detox/DetoxANRHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.wix.detox | ||
|
||
import android.util.Log | ||
import com.github.anrwatchdog.ANRWatchDog | ||
|
||
class DetoxANRHandler(private val wsClient: WebSocketClient) { | ||
fun attach() { | ||
ANRWatchDog().setReportMainThreadOnly().setANRListener { | ||
val info = mapOf("threadDump" to Log.getStackTraceString(it)) | ||
wsClient.sendAction(ACTION_NAME, info, MESSAGE_ID) | ||
}.start() | ||
|
||
ANRWatchDog().setANRListener { | ||
Log.e(LOG_TAG, "App nonresnponsive detection!", it) | ||
}.start() | ||
} | ||
|
||
companion object { | ||
val LOG_TAG: String = DetoxANRHandler::class.java.simpleName | ||
|
||
private const val ACTION_NAME = "AppNonresponsiveDetected" | ||
private const val MESSAGE_ID = -10001L | ||
} | ||
} |
9 changes: 4 additions & 5 deletions
9
detox/android/detox/src/main/java/com/wix/detox/DetoxCrashHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
package com.wix.detox | ||
|
||
import android.util.Log | ||
import org.apache.commons.lang3.exception.ExceptionUtils | ||
|
||
class DetoxCrashHandler(private val wsClient: WebSocketClient) { | ||
fun attach() { | ||
Thread.setDefaultUncaughtExceptionHandler { thread, exception -> | ||
Log.e(LOG_TAG, "Crash detected!!! thread=${thread.name} (${thread.id})") | ||
|
||
val crashInfo = mapOf("errorDetails" to "@Thread ${thread.name}(${thread.id}):\n${ExceptionUtils.getStackTrace(exception)}") | ||
wsClient.sendAction(APP_CRASH_ACTION_NAME, crashInfo, APP_CRASH_MESSAGE_ID) | ||
val crashInfo = mapOf("errorDetails" to "@Thread ${thread.name}(${thread.id}):\n${Log.getStackTraceString(exception)}") | ||
wsClient.sendAction(ACTION_NAME, crashInfo, MESSAGE_ID) | ||
} | ||
} | ||
|
||
companion object { | ||
val LOG_TAG: String = DetoxCrashHandler::class.java.simpleName | ||
|
||
const val APP_CRASH_ACTION_NAME = "AppWillTerminateWithError" | ||
const val APP_CRASH_MESSAGE_ID = -10000L | ||
private const val ACTION_NAME = "AppWillTerminateWithError" | ||
private const val MESSAGE_ID = -10000L | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.