From e9d42361a05903b9471f5b078eead1a654f0b564 Mon Sep 17 00:00:00 2001 From: mcarare Date: Thu, 6 Jan 2022 17:25:38 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/22559: Update leak canary version to 2.8.1 --- .../fenix/perf/StartupExcessiveResourceUseTest.kt | 2 +- .../org/mozilla/fenix/DebugFenixApplication.kt | 15 +++++++++++++-- buildSrc/src/main/java/Dependencies.kt | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt index 577e7ba65e..68b361cddd 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/perf/StartupExcessiveResourceUseTest.kt @@ -21,7 +21,7 @@ import org.mozilla.fenix.ext.components import org.mozilla.fenix.helpers.HomeActivityTestRule // BEFORE INCREASING THESE VALUES, PLEASE CONSULT WITH THE PERF TEAM. -private const val EXPECTED_SUPPRESSION_COUNT = 19 +private const val EXPECTED_SUPPRESSION_COUNT = 20 @Suppress("TopLevelPropertyNaming") // it's silly this would have a different naming convention b/c no const private val EXPECTED_RUNBLOCKING_RANGE = 0..1 // CI has +1 counts compared to local runs: increment these together private const val EXPECTED_RECYCLER_VIEW_CONSTRAINT_LAYOUT_CHILDREN = 4 diff --git a/app/src/debug/java/org/mozilla/fenix/DebugFenixApplication.kt b/app/src/debug/java/org/mozilla/fenix/DebugFenixApplication.kt index 7825870b01..76dc85afad 100644 --- a/app/src/debug/java/org/mozilla/fenix/DebugFenixApplication.kt +++ b/app/src/debug/java/org/mozilla/fenix/DebugFenixApplication.kt @@ -8,20 +8,31 @@ import android.os.StrictMode import androidx.preference.PreferenceManager import leakcanary.AppWatcher import leakcanary.LeakCanary +import org.mozilla.fenix.ext.application import org.mozilla.fenix.ext.getPreferenceKey class DebugFenixApplication : FenixApplication() { override fun setupLeakCanary() { + if (!AppWatcher.isInstalled) { + AppWatcher.manualInstall( + application = application, + watchersToInstall = AppWatcher.appDefaultWatchers(application) + ) + } + val isEnabled = components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(getPreferenceKey(R.string.pref_key_leakcanary), true) } + updateLeakCanaryState(isEnabled) } override fun updateLeakCanaryState(isEnabled: Boolean) { - AppWatcher.config = AppWatcher.config.copy(enabled = isEnabled) - LeakCanary.config = LeakCanary.config.copy(dumpHeap = isEnabled) + LeakCanary.showLeakDisplayActivityLauncherIcon(isEnabled) + components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { + LeakCanary.config = LeakCanary.config.copy(dumpHeap = isEnabled) + } } } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 9a78a9f726..3b2536bfcb 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -15,7 +15,7 @@ object Versions { const val android_lint_api = "30.0.0" const val sentry = "1.7.10" - const val leakcanary = "2.4" + const val leakcanary = "2.8.1" const val osslicenses_plugin = "0.10.4" const val detekt = "1.17.1" const val jna = "5.6.0" @@ -172,7 +172,7 @@ object Deps { const val mozilla_support_locale = "org.mozilla.components:support-locale:${Versions.mozilla_android_components}" const val sentry = "io.sentry:sentry-android:${Versions.sentry}" - const val leakcanary = "com.squareup.leakcanary:leakcanary-android:${Versions.leakcanary}" + const val leakcanary = "com.squareup.leakcanary:leakcanary-android-core:${Versions.leakcanary}" const val androidx_compose_ui = "androidx.compose.ui:ui:${Versions.androidx_compose}" const val androidx_compose_ui_test = "androidx.compose.ui:ui-test-junit4:${Versions.androidx_compose}"