Blind fix for user switcher instant crash.
There is an instant crash stemming from a premature optimization done in the newly refactored code for the user switcher system. I am unable to reproduce this locally, so this is a blind fix. What follows is the rationale behind it. It appears to be a race condition. UserRepositoryImpl#isSimpleUserSwitcher asserts that we have loaded the settings but the settings are only loaded in a background coroutine job that's kicked off when the repository class is instantiated. From the looks of it, the former path is triggered before the latter is. The fix, therefore, is to always make sure that there is a non-null value for user settings. This is achieved in this CL using an expensive runBlocking call at class instantiation time. Delaying that was an optimization that attempted to do better than the original pre-refactor code, where the same approach is taken (settings are accessed on the main thread in a blocking fashion). Fix: 255916597, 254764031 Test: unable to reproduce locally but made sure that, with the new changes, there is no instant crash nor a crash when entering the full-screen user switcher on one of the affected device models - used adb reboot to trigger restarts. Change-Id: I970a416ae7eaf2d2a366b12b3d7c6b98ebc52011
Loading
Please register or sign in to comment