Skip to content

[Bug]: Electrum config connect ANR in isValidURL regex on main thread #1068

Description

@piotr-iohk

What happened?

On production 2.3.1 (build 184), Play Vitals reports 1 ANR (1 user, 1 event) with stack:

Input dispatching timed out
  at kotlin.text.Regex.matches (Regex.kt:108)
  at to.bitkit.ui.settings.advanced.ElectrumConfigViewModel.isValidURL (ElectrumConfigViewModel.kt:209)
  at to.bitkit.ui.settings.advanced.ElectrumConfigViewModel.validateInput (ElectrumConfigViewModel.kt:189)
  at to.bitkit.ui.settings.advanced.ElectrumConfigViewModel$onClickConnect$1.invokeSuspend (ElectrumConfigViewModel.kt:249)
  at to.bitkit.ui.settings.advanced.ElectrumConfigViewModel.onClickConnect (ElectrumConfigViewModel.kt:248)

User tapped Connect on the Electrum server settings screen. URL validation runs a hostname Regex.matches() call via ICU native matcher (libicui18n.so), blocking the main thread long enough to trigger an ANR.

Expected behavior

Tapping Connect should validate host/port quickly and either show a validation toast or proceed to connect — without freezing the UI.

Steps to Reproduce

  1. Open Settings → Advanced → Electrum server (custom server config).
  2. Enter a host string that may stress the hostname regex (exact production input unknown; likely long/malformed host before port).
  3. Tap Connect.
  4. UI hangs; ANR dialog may appear.

Code path: onClickConnect()viewModelScope.launch (Main) → validateInput()isValidURL()hostname.matches(Regex(...)) at line 209.

Likely fix direction: move validation off main thread and/or replace regex with URI parsing (see RgsServerViewModel.isValidURL pattern).

Logs / Screenshots / Recordings

  • Play Vitals screenshot (2026-07-13 weekly report)
  • Stack trace above (Play Console ANR details)

Bitkit Version

2.3.1 (build 184) — production mainnet

Device / OS

Motorola moto g - 2025, Android 16 (SDK 36). Occurred ~4 days before report (Play Vitals sample).

Reproducibility

Rarely (once or twice) — 1 user / 1 event on 2.3.1 since Jun 29 rollout.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions