android: optimize split-tunnel app picker#808
Open
supfeer wants to merge 1 commit into
Open
Conversation
0bd812a to
f49bec7
Compare
Updates tailscale/tailscale#19901 Signed-off-by: supfeer <supfeer@gmail.com>
f49bec7 to
80c74e8
Compare
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
The split-tunnel app picker can become expensive to render on devices with many installed apps.
Before this change, the picker:
PackageManager.GET_META_DATA;ListItemfor every app row;List.contains(...)call for each row;On devices with many installed applications, fast scrolling could stutter because row composition could trigger package manager icon lookups and bitmap conversion. In worse cases, repeated icon work during long downward scrolling could increase memory pressure and make the picker unstable enough to crash.
When that happened, apps near the end of the list could not be reached reliably, which meant users could be unable to add those packages to the split-tunnel include or exclude list.
The picker also had no filter/search control, so users with many installed apps had to scroll through the full list to find a specific package.
Changes
This change makes the split-tunnel app picker cheaper to render and easier to use.
Performance
InstalledAppsManager.Rowinstead ofListItem.contentTypeforLazyColumn.items.Setfor O(1) row selection checks.Filtering
Ordering
Related issues
Updates tailscale/tailscale#19901.
Testing
Added unit coverage for the app ordering/filtering behavior, including:
Verified locally with:
./gradlew ktfmtCheck test assembleDebug