Prevent duplicate subscription IDs from crashing Compose lists - #6172
Merged
2dust merged 1 commit intoSep 5, 2026
Merged
Conversation
A saved SUB_IDS array can contain the same GUID more than once. Loading it verbatim creates repeated subscription rows with identical Compose and reorderable-list keys, which can crash the subscription screen. Deduplicate IDs in the shared reader while preserving the first-seen order and mutable-list contract. This protects every index consumer without changing subscription records, generating replacement IDs, or adding writes during reads. Different subscriptions with identical or blank names remain separate. Add six regression tests for duplicate rows, stable ordering, read-only decoding, mutable round trips, repeated names, and existing empty/invalid input behavior. Three assertions fail on unchanged upstream; all six pass with the fix. The full 63-test suite and Play Store debug build pass. On the API 37.1 Pixel 9 Pro emulator, a deliberately duplicated saved index loaded each subscription once, retained first-occurrence order, reopened safely, and edited the correct record. The raw index remained duplicated throughout the check; no app crash was observed.
Owner
|
会存在重复的ID 吗? |
Maolaohei
pushed a commit
to Maolaohei/v2rayNG
that referenced
this pull request
Sep 7, 2026
A saved SUB_IDS array can contain the same GUID more than once. Loading it verbatim creates repeated subscription rows with identical Compose and reorderable-list keys, which can crash the subscription screen. Deduplicate IDs in the shared reader while preserving the first-seen order and mutable-list contract. This protects every index consumer without changing subscription records, generating replacement IDs, or adding writes during reads. Different subscriptions with identical or blank names remain separate. Add six regression tests for duplicate rows, stable ordering, read-only decoding, mutable round trips, repeated names, and existing empty/invalid input behavior. Three assertions fail on unchanged upstream; all six pass with the fix. The full 63-test suite and Play Store debug build pass. On the API 37.1 Pixel 9 Pro emulator, a deliberately duplicated saved index loaded each subscription once, retained first-occurrence order, reopened safely, and edited the correct record. The raw index remained duplicated throughout the check; no app crash was observed. (cherry picked from commit f4f992e)
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.
Summary
Prevent duplicate entries in the persisted subscription index from producing duplicate Compose keys. The production change is one
distinct()call inMmkvManager.decodeSubsList(), with a short explanatory comment and six regression tests.Why
Subscription records are stored by GUID, while their display order is stored separately in the
MAIN/SUB_IDSJSON array. If that array contains repeated GUIDs,decodeSubscriptions()currently emits the same record repeatedly. Both the subscriptionLazyColumnand its reorderable items use that GUID as their key, so a damaged index can cause a duplicate-key Compose crash.For example, with existing records
a,b, andc:This is defensive handling of already-duplicated stored data, not a claim that creating subscriptions with the same name produces duplicate IDs.
Scope and behavior
No UI, localization, native-library, or dependency changes. Based directly on current
upstream/master; independent of the accessibility changes in #6158.Validation
:app:testPlaystoreDebugUnitTest --tests com.v2ray.ang.handler.SubscriptionIndexTest.:app:testPlaystoreDebugUnitTest: 63 tests passed.:app:compilePlaystoreDebugKotlinand:app:assemblePlaystoreDebug: passed.