-
Notifications
You must be signed in to change notification settings - Fork 475
Close #9829: Move IO work in FxaPushSupportFeature to a coroutine #12687
Conversation
I tried testing this on Fenix using the following changes:
However, Fenix crashed and I saw the following exception in the log:
It looks like there's a threading issue to me, although I'm very over my head. I can try to run some more tests if it would be helpful. |
@bendk thanks for testing, that was super helpful! I made the mistake of not updating my Fenix patch to use the new
The fix here is to ensure that the account manager and push observers are added to those features only on the Main thread. Since any feature that touches the account manager would end up initializing Fenix, we may end up adding these observers off the main thread and we've been getting pretty lucky so far. This change made it very explicit that we run into this situation, so I've updated my patch to switch the main dispatcher when adding the above observers: coroutineScope.launch(Main) {
accountManager.register(accountObserver)
pushFeature.register(autoPushObserver, owner, autoPause)
} |
Just tested with the new changes and it worked great. I don't think I'm qualified to review the patch in general, but it seems good to me. |
This pull request has conflicts when rebasing. Could you fix it @jonalmeida? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one nit below. I like that we now have an explicit initialize
call and all this work doesn't happen as a side effect of the feature's constructor.
...ccounts-push/src/main/java/mozilla/components/feature/accounts/push/FxaPushSupportFeature.kt
Outdated
Show resolved
Hide resolved
… coroutine The `FxaPushSupportFeature` needs to generate, read and write a push scope (identifier) to disk. This work was meant to be done lazily and not during app startup. However, if a Sync account is setup then the IO work is done immediately during the initial account manager initialization at startup. In this patch, we delegate this IO work to a new `PushScopeProperty` that retrieves the value from disk using a provided `CoroutineScope`.
The
FxaPushSupportFeature
needs to generate, read and write a pushscope (identifier) to disk. This work was meant to be done lazily and
not during app startup. However, if a Sync account is setup then the IO
work is done immediately during the initial account manager
initialization at startup.
In this patch, we delegate this IO work to a new
PushScopeProperty
that retrieves the value from disk using a provided
CoroutineScope
.Pull Request checklist
After merge
GitHub Automation
Fixes #9829