[MS-923] Adding internal counter for the amount of loaded candidates in the MatchViewModel#1126
Merged
meladRaouf merged 1 commit intoMar 5, 2025
Conversation
…in MatchViewModel. This way the new state does need to access old state for update, and no longer exhausts resources to send updates to the LiveData observer
meladRaouf
approved these changes
Mar 5, 2025
|
luhmirin-s
approved these changes
Mar 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue description
The
MatchViewModelobserves theLoadingCandidatesevent from the Matcher UseCase and emits it to the LiveData's Observer. TheLoadingCandidatesevent that might be emitted multiple times a second.We've observed that the UI layer processed less than 5% of the events sent to the LiveData:
43819events emitted by the Use Case43819events forwarded to the LiveData by the ViewModel (0% loss)2372- received by the observer (MatchFragment, >90% loss)Not only the events were being lost, the Observer stopped receiving them after some arbitrary threshold - after ~20 events on some devices, ~4000 events on others.
Fix
It was identified that by removing the state reference to itself for update, the issue disappears.
was changed to
This way the new state does need to access old state for update, and no longer exhausts resources to send updates to the LiveData observer.
Video before the update:
callback-issue.mp4
Video after the update:
Local database
flow-counter.mp4
CoSync
cosync-counter-id.mp4