fix: reduce GC pressure on Search tab for low-end devices - #1202
Open
sang765 wants to merge 2 commits into
Open
Conversation
Batch concurrent network requests in loadSuggestedSongs() and loadSuggestedArtists() to prevent GcWatcher.finalize() timeout crashes on low-RAM devices (e.g. 512MB MT6580). - Process seed items in batches of 3 instead of all at once - Add yield() between batches to let GC breathe - Lower MaxSuggestionSeedItems from 6 to 4
Contributor
Author
|
Is tested on low-end emulator. This is smaller patch but need to fix |
sang765
marked this pull request as ready for review
August 21, 2026 01:21
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
Crash on low-end device (Android 8.1, MT6580, ~512MB RAM) when navigating to the Search tab:
Root Cause
SearchDiscoveryRepository.loadDiscovery()fires ~17 concurrent network calls simultaneously:YouTube.next()calls for suggested songsYouTube.artist()calls for suggested artistsEach response creates large object graphs (SongItem, AlbumItem, ArtistItem). On a 512MB device, this burst of allocations overwhelms the GC.
Fix
loadSuggestedSongs()andloadSuggestedArtists()now process seed items in batches of 3 (chunked(ConcurrentRequestBatchSize)) instead of all 6 at onceyield()between batches gives GC a checkpoint to reclaim memoryMaxSuggestionSeedItemslowered from 6 to 4 (fewer total calls, negligible quality difference since results are capped at 12)Before: ~17 concurrent network calls at peak
After: Max ~8 concurrent at any moment, with GC yield between batches
Testing
Verified on low-end device (MT6580, 512MB RAM, Android 8.1) — Search tab no longer crashes.