Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecordRulesViewModel: Fix race condition when mutating rules #555

Merged
merged 3 commits into from
Jun 7, 2024

Conversation

chenxiaolong
Copy link
Owner

BCR can potentially be unloaded from memory when the user is in Android's contact picker activity. If this happens, when they return, the coroutines in refreshRules() and addContactRule() may execute at the same time. This does not cause crashes due to MutableStateFlow's compare and set behavior, but does cause weird behavior, like the new contact rule being added to an empty list of rules.

Fixes: #554

BCR can potentially be unloaded from memory when the user is in
Android's contact picker activity. If this happens, when they return,
the coroutines in refreshRules() and addContactRule() may execute at the
same time. This does not cause crashes due to MutableStateFlow's compare
and set behavior, but does cause weird behavior, like the new contact
rule being added to an empty list of rules.

Fixes: #554

Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong chenxiaolong self-assigned this Jun 6, 2024
@chenxiaolong chenxiaolong merged commit abf6579 into master Jun 7, 2024
1 check passed
@chenxiaolong chenxiaolong deleted the record-rules-race-condition branch June 7, 2024 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to add more than 2 contact rules
1 participant