[BUG]: Platform parameter syncing races against SplashActivity #5676
Labels
bug
End user-perceivable behaviors which are not desirable.
Impact: High
High perceived user impact (breaks a critical feature or blocks a release).
triage needed
Milestone
Describe the bug
Currently, platform parameter syncing relies on a application-scope singleton to be fully initialized before its properties will be correctly retrieved from the local data store. See:
oppia-android/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterController.kt
Line 50 in 4f58be9
And
oppia-android/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterModule.kt
Lines 88 to 89 in 4f58be9
Yet, the singleton gracefully fails:
oppia-android/domain/src/main/java/org/oppia/android/domain/platformparameter/PlatformParameterSingletonImpl.kt
Lines 47 to 49 in 4f58be9
And
SplashActivityPresenter
relies on app-critical features during construction:oppia-android/app/src/main/java/org/oppia/android/app/splash/SplashActivityPresenter.kt
Lines 78 to 79 in 4f58be9
I have not tested this, but I strongly suspect that if the quite failure logic were to be updated above to fail with an exception that splash activity would always fail (which means it will never have a synced state). This, in turn, means that OS and app deprecation will never work correctly in the current implementation.
Steps To Reproduce
I haven't devised actual steps to repro the issue.
Expected Behavior
State needs to be synced such that even splash activity can have platform parameters upon starting.
Screenshots/Videos
No response
What device/emulator are you using?
No response
Which Android version is your device/emulator running?
No response
Which version of the Oppia Android app are you using?
No response
Additional Context
I think that this could probably be solved by introducing a hard block on
PlatformParameterController
during startup. Normally, this would happen inSplashActivity
but it seems that may not be an option sinceSplashActivity
is doing a lot of other stuff.This is actually rather tricky: we want the Dagger injections to be non-blocking (which means there does need to be some state syncing ahead of injection), but we need a good point in the app startup cycle to perform this logic. My current thinking is that we should:
PlatformParameterController.syncAppState()
function which force-refreshes the local state used by providers).I'm not very keen on the mechanisms of the last option since it still leaves the possibility of having broken Dagger state, but short of introducing Hilt and carefully managed Dagger components, it's probably a reasonable approach.
The text was updated successfully, but these errors were encountered: