Resolve startup crashes in debug build
There are some startup crashes when running a debug build:
10-27 19:35:43.370 6296 6296 E AndroidRuntime: FATAL EXCEPTION: main
10-27 19:35:43.370 6296 6296 E AndroidRuntime: Process: org.torproject.torbrowser_debug, PID: 6296
10-27 19:35:43.370 6296 6296 E AndroidRuntime: java.lang.RuntimeException: StrictMode ThreadPolicy violation
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1768)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.lambda$handleViolationWithTimingAttempt$0$StrictMode$AndroidBlockGuardPolicy(StrictMode.java:1687)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.-$$Lambda$StrictMode$AndroidBlockGuardPolicy$9nBulCQKaMajrWr41SB7f7YRT1I.run(Unknown Source:6)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: Caused by: android.os.strictmode.DiskReadViolation
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.app.SharedPreferencesImpl.awaitLoadedLocked(SharedPreferencesImpl.java:261)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at android.app.SharedPreferencesImpl.getBoolean(SharedPreferencesImpl.java:330)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at mozilla.components.support.ktx.android.content.BooleanPreference.getValue(SharedPreferences.kt:26)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at mozilla.components.support.ktx.android.content.BooleanPreference.getValue(SharedPreferences.kt:20)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.tor.bootstrap.TorQuickStart.getTorQuickStart(Unknown Source:7)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.tor.bootstrap.TorQuickStart.quickStartTor(TorQuickStart.kt:22)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.home.CurrentMode.getCurrentMode(Mode.kt:67)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment$onCreateView$2.invoke(HomeFragment.kt:219)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment$onCreateView$2.invoke(HomeFragment.kt:120)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.components.StoreProviderFactory.create(StoreProvider.kt:42)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:187)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.components.StoreProvider$Companion.get(StoreProvider.kt:46)
10-27 19:35:43.370 6296 6296 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment.onCreateView(HomeFragment.kt:214)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: java.security.UnrecoverableKeyException: Failed to obtain information about key
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreProvider.getKeyCharacteristics(AndroidKeyStoreProvider.java:242)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreKeyFromKeystore(AndroidKeyStoreProvider.java:364)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:105)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at java.security.KeyStore.getKey(KeyStore.java:1062)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.KeyStoreWrapper.getKeyFor(Keystore.kt:72)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.Keystore.getKey(Keystore.kt:159)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.Keystore.available(Keystore.kt:168)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.SecurePreferencesImpl23.generateManagedKeyIfNecessary(SecureAbove22Preferences.kt:227)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.SecurePreferencesImpl23.getString(SecureAbove22Preferences.kt:187)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at mozilla.components.lib.dataprotect.SecureAbove22Preferences.getString(SecureAbove22Preferences.kt:76)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$passwordsEncryptionKey$2.invoke(Core.kt:335)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$passwordsEncryptionKey$2.invoke(Core.kt:78)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core.getPasswordsEncryptionKey(Unknown Source:2)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core.access$getPasswordsEncryptionKey$p(Core.kt:78)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$lazyPasswordsStorage$1.invoke(Core.kt:256)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$lazyPasswordsStorage$1.invoke(Core.kt:78)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$passwordsStorage$2.invoke(Core.kt:266)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core$passwordsStorage$2.invoke(Core.kt:78)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.components.Core.getPasswordsStorage(Unknown Source:2)
10-27 18:21:45.364 6463 6522 E AndroidRuntime: at org.mozilla.fenix.FenixApplication$initVisualCompletenessQueueAndQueueTasks$3$1$1.invokeSuspend(FenixApplication.kt:227)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: FATAL EXCEPTION: main
10-27 21:33:56.760 6934 6934 E AndroidRuntime: Process: org.torproject.torbrowser_debug, PID: 6934
10-27 21:33:56.760 6934 6934 E AndroidRuntime: java.lang.RuntimeException: StrictMode ThreadPolicy violation
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onThreadPolicyViolation(StrictMode.java:1768)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.lambda$handleViolationWithTimingAttempt$0$StrictMode$AndroidBlockGuardPolicy(StrictMode.java:1687)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.-$$Lambda$StrictMode$AndroidBlockGuardPolicy$9nBulCQKaMajrWr41SB7f7YRT1I.run(Unknown Source:6)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:883)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:100)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: Caused by: android.os.strictmode.DiskReadViolation
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1556)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at libcore.io.BlockGuardOs.access(BlockGuardOs.java:69)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at libcore.io.ForwardingOs.access(ForwardingOs.java:73)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ActivityThread$AndroidOs.access(ActivityThread.java:7246)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:281)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at java.io.File.exists(File.java:815)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:645)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:636)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ContextImpl.getPreferencesDir(ContextImpl.java:592)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferencesPath(ContextImpl.java:787)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:439)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:178)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:178)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at org.mozilla.fenix.tor.bootstrap.TorQuickStart.<init>(TorQuickStart.kt:17)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment$torQuickStart$2.invoke(HomeFragment.kt:170)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment$torQuickStart$2.invoke(HomeFragment.kt:120)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment.getTorQuickStart(Unknown Source:2)
10-27 21:33:56.760 6934 6934 E AndroidRuntime: at org.mozilla.fenix.home.HomeFragment.onCreateView(HomeFragment.kt:205)
Edited by Matthew Finkel