Open
Conversation
…iled once instead of on every keystroke
app/src/main/java/to/bitkit/ui/settings/advanced/RgsServerViewModel.kt
Outdated
Show resolved
Hide resolved
… that caused catastrophic backtracking in the ICU regex engine on Android, running on every keystroke on the main thread
app/src/test/java/to/bitkit/ui/settings/advanced/RgsServerViewModelTest.kt
Fixed
Show fixed
Hide fixed
Member
Author
LDK RGS is not reachable for me |
Member
Author
|
the correct address is |
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.
Description
This PR fixes an ANR (Application Not Responding) crash on the RGS Server settings screen caused by catastrophic regex backtracking.
The
URL_PATTERNregex had a nested quantifier(/[-a-z\d%_.~+]*)*that triggered exponential backtracking in Android's ICU regex engine. SinceisValidURLran on every keystroke on the main thread viacomputeState, certain URL inputs would freeze the app for 5+ seconds, triggering an ANR.This PR:
java.net.URIparsing + simple hostname/path patterns (matching the approach already used inElectrumConfigViewModel)UrlValidatorbefore restarting the node, preventing invalid RGS URLs from being savedRgsServerViewModelandLightningRepo.restartWithRgsServer, including timeout-based tests to detect backtracking regressionsPreview
Screen_recording_20260401_140552.webm
QA Notes
1. No ANR when typing URLs
https://rapidsync.lightningdevkit.org/snapshotcharacter by character2. Invalid RGS host shows error toast
https://rapidsync.lightningdevkit.org/snapdsadaDSFas RGS URL3. Valid RGS host connects successfully
4. Unit tests
./gradlew testDevDebugUnitTest --tests "to.bitkit.ui.settings.advanced.RgsServerViewModelTest"— 19 tests pass./gradlew testDevDebugUnitTest --tests "to.bitkit.repositories.LightningRepoTest"— all tests pass including 4 new RGS tests