Repository navigation
perf: fix launch freeze (settings flow on main, off-screen tabs) - #644
Merged
Merged
Conversation
Statistics and Playlists were composed on the launch frame and started their own loads, recomposing off-screen while the Feed did its first load. Compose them once the user first leaves the Feed, then keep every tab composed as before so a dock jump back never rebuilds the Feed.
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
A user reported the app freezing for 3–4 s on launch, plus stutter when the feed auto-refreshes.
On a CPH2649 (Snapdragon 8 Elite, release build), every cold start had 3 frames of 450–700 ms. Frame stats put all of that time before the frame starts (vsync →
HandleInputStart), not in drawing. A scheduler trace shows the main thread running flat out for 439, 624 and 520 ms at those exact moments, in code that emits no trace sections. A method-sampling trace of the debuggable build attributes the work outside frames toSettingsPreferences.settingsmapping (map…emit+collect+Keysinit) and to BotGuard's WebView creation.Changes
SettingsPreferences.settings: this was a cold flow. Each of ~60 collectors, most on Main, re-ran the ~100-key mapping and the addons JSON parse on every write to the DataStore. It now maps once per change onDispatchers.Default, skips unchanged values, and shares the latest one (shareIn,replay = 1). The type staysFlow<MiscSettings>, so callers are unchanged;first()anddrop(1)behave as before.MainShellpager: Statistics and Playlists were composed on the launch frame and started their own loads. They are now composed once the user first leaves the Feed, then kept composed as before, so a dock jump back to Feed still never rebuilds it.Measured
Change 2, non-debuggable bench build, OnePlus Pad, 5 cold starts each:
Change 1 compiles but has not been run on a device (local builds ran out of memory). Please check it on device before merging.
Not covered
verify-compiled. Aftercmd package compile -m speed-profilethere are 0 frames over 16 ms. So it comes from running without AOT after each sideloaded update, until Android's background dexopt applies the baseline profile. No code change here.FeedViewModel.onVisible()refreshes after 90 s and the feed is rebuilt for each of 3–4 progressive updates. Unchanged; a repro on the CPH2649 showed one 53 ms frame.