Skip to content

Commit

Permalink
Add NDK service tracing (#535)
Browse files Browse the repository at this point in the history
## Goal

Add more tracing for what the NDK service is doing.
  • Loading branch information
bidetofevil committed Mar 11, 2024
2 parents 5e18d90 + 948894d commit d6d0238
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger
internal class SharedObjectLoader {

fun loadEmbraceNative() = try {
System.loadLibrary("embrace-native")
Systrace.traceSynchronous("load-embrace-native-lib") {
System.loadLibrary("embrace-native")
}
true
} catch (exc: UnsatisfiedLinkError) {
InternalStaticEmbraceLogger.logError("Failed to load SO file embrace-native", exc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,14 @@ internal class EmbraceNdkService(
null
}
if (configService.autoDataCaptureBehavior.isNdkEnabled()) {
processStateService.addListener(this)
if (appFramework == AppFramework.UNITY) {
unityCrashId = getEmbUuid()
Systrace.traceSynchronous("init-ndk-service") {
processStateService.addListener(this)
if (appFramework == AppFramework.UNITY) {
unityCrashId = getEmbUuid()
}
startNdk()
cleanOldCrashFiles()
}

Systrace.traceSynchronous("start-ndk-service") { startNdk() }
Systrace.traceSynchronous("clear-stale-crashes") { cleanOldCrashFiles() }
}
}

Expand Down Expand Up @@ -230,26 +231,31 @@ internal class EmbraceNdkService(
"EmbraceNDKService",
"Installing signal handlers. 32bit=$is32bit, crashId=$nativeCrashId"
)
val initialMetaData = serializer.toJson(
NativeCrashMetadata(
metadataService.getLightweightAppInfo(),
metadataService.getLightweightDeviceInfo(),
userService.getUserInfo(),
sessionProperties.get().toMap()

val initialMetaData = Systrace.traceSynchronous("init-native-crash-metadata") {
serializer.toJson(
NativeCrashMetadata(
metadataService.getLightweightAppInfo(),
metadataService.getLightweightDeviceInfo(),
userService.getUserInfo(),
sessionProperties.get().toMap()
)
)
)
delegate._installSignalHandlers(
reportBasePath,
markerFilePath,
initialMetaData,
"null",
metadataService.getAppState(),
nativeCrashId,
Build.VERSION.SDK_INT,
is32bit,
ApkToolsConfig.IS_DEVELOPER_LOGGING_ENABLED
)
updateDeviceMetaData()
}
Systrace.traceSynchronous("native-install-handlers") {
delegate._installSignalHandlers(
reportBasePath,
markerFilePath,
initialMetaData,
"null",
metadataService.getAppState(),
nativeCrashId,
Build.VERSION.SDK_INT,
is32bit,
ApkToolsConfig.IS_DEVELOPER_LOGGING_ENABLED
)
}
Systrace.traceSynchronous("update-metadata") { updateDeviceMetaData() }
isInstalled = true
}

Expand Down

0 comments on commit d6d0238

Please sign in to comment.