From 79ab29eff23031e356d19fd616fc2f9d7ffbbf77 Mon Sep 17 00:00:00 2001 From: Christian Sadilek Date: Tue, 27 Oct 2020 16:43:57 -0400 Subject: [PATCH] [fenix] No issue: Fix onConfigurationChange crashes in Debug build --- .../main/java/org/mozilla/fenix/FenixApplication.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index 086035b130..64a76a0679 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -431,8 +431,17 @@ open class FenixApplication : LocaleAwareApplication(), Provider { // https://issuetracker.google.com/issues/143570309#comment3 applicationContext.resources.configuration.uiMode = config.uiMode - // random StrictMode onDiskRead violation even when Fenix is not running in the background. - components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { + if (isMainProcess()) { + // We can only do this on the main process as resetAfter will access components.core, which + // will initialize the engine and create an additional GeckoRuntime from the Gecko + // child process, causing a crash. + + // There's a strict mode violation in A-Cs LocaleAwareApplication which + // reads from shared prefs: https://github.com/mozilla-mobile/android-components/issues/8816 + components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { + super.onConfigurationChanged(config) + } + } else { super.onConfigurationChanged(config) } }