Cast: Fix thread safety and memory leak in CastMediaRouteProvider#3354
Open
koczadly wants to merge 3 commits intomicrog:masterfrom
Open
Cast: Fix thread safety and memory leak in CastMediaRouteProvider#3354koczadly wants to merge 3 commits intomicrog:masterfrom
koczadly wants to merge 3 commits intomicrog:masterfrom
Conversation
- Make fields final - Use diamond operator - Use StandardCharsets value over string-based lookup
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.
Problem
CastMediaRouteProviderhas no thread synchronisation for its shared mutable state, which can be accessed across numerous threads (NSD callbacks + main thread).This has been causing
ConcurrentModificationExceptioncrashes, which seems to be consistently reproducible whenever opening the Google Home app.Stacktrace
The inner
customCategoriescollection is also appended to for every discovery request, causing it to grow indefinitely.Changes
lockobject to guard shared stateSetand replacing contents on each discovery requestTesting
Just to note, I have the ReVanced version installed on my device as I do not have root-level access. I understand their fork has a few minor differences, though this specific implementation appears to be completely unchanged.
I have deployed these changes onto my personal device and it has been working as expected.
Issues
Fixes #2449