Fix ANRs when calculating DB sizes for Sentry (#7017)

* Fix ANRs when calculating DB sizes for Sentry

Instead of using the SDK's `Client.getStoreSizes()` method, manually check the sizes using the file system.

For this, the `SessionPaths` need to be synchronously accessible from a `MatrixClient`. I removed `SessionPathsProvider` too since it's not needed anymore.
This commit is contained in:
Jorge Martin Espinosa
2026-06-16 16:49:09 +02:00
committed by GitHub
parent 8e9c0bedf2
commit ac93044f49
19 changed files with 88 additions and 101 deletions
@@ -33,7 +33,6 @@ import io.sentry.Sentry
import io.sentry.SentryOptions
import io.sentry.android.core.SentryAndroid
import io.sentry.protocol.SentryTransaction
import kotlinx.coroutines.runBlocking
import timber.log.Timber
@ContributesIntoSet(AppScope::class)
@@ -132,7 +131,7 @@ class SentryAnalyticsProvider(
if (sessionId != null) {
// This runs in a separate thread, so although using `runBlocking` is not great, at least it shouldn't freeze the app
// Also, the method is fairly quick, so the blocking shouldn't take longer than a few ms
val databaseSizes = runBlocking { getDatabaseSizesUseCase(sessionId) }.getOrNull()
val databaseSizes = getDatabaseSizesUseCase(sessionId).getOrNull()
databaseSizes?.stateStore?.let { transaction.setExtra(AnalyticsUserData.STATE_STORE_SIZE, it.into(ByteUnit.MB)) }
databaseSizes?.eventCacheStore?.let { transaction.setExtra(AnalyticsUserData.EVENT_CACHE_SIZE, it.into(ByteUnit.MB)) }