ElectrumClient constructor performs blocking network I/O, causing ANR when called on UI thread
Summary
uniffi_bdkffi_fn_constructor_electrumclient_new performs a synchronous, blocking TCP connect() during construction. When invoked from a platform main/UI thread (e.g. via flutter_rust_bridge / FFI on Android), this blocks the UI thread and produces an Application Not Responding (ANR).
Environment
- bdk-ffi (Dart/Flutter bindings,
libbdk_dart_ffi.so)
- Platform: Android (ARM64)
- App: Flutter, BDK called over FFI
Severity
High. On Android, ANRs are tracked in Google Play's Android vitals. Apps that exceed Play's ANR rate threshold receive a "bad behavior" warning in the Play Console and can have their store visibility/discoverability reduced. A constructor that can hang the UI thread on a slow or unreachable Electrum server means any production app shipping bdk-ffi risks elevated ANR rates — making this a release-blocking issue for Flutter wallets in production.
Stack trace (main thread)
main (native):tid=1
#00 pc 0x9bd34 libc.so (__connect + 4)
#01 pc 0x48e4 libnetd_client.so (netdClientConnect + 280)
#02 pc 0xdd6864 libbdk_dart_ffi.so
#03 pc 0x846a84 libbdk_dart_ffi.so
#04 pc 0x82e6b0 libbdk_dart_ffi.so
#05 pc 0x843cfc libbdk_dart_ffi.so
#06 pc 0x843e5c libbdk_dart_ffi.so
#07 pc 0x6d9a38 libbdk_dart_ffi.so
#08 pc 0x535868 libbdk_dart_ffi.so
#09 pc 0x6d9684 libbdk_dart_ffi.so (uniffi_bdkffi_fn_constructor_electrumclient_new + 104)
#10 pc 0x601628 libapp.so <-- Dart caller
The main thread is parked inside __connect — the network round-trip to the Electrum server runs synchronously on the UI thread.
Expected behavior
Constructing an ElectrumClient should not block the calling thread on network I/O, or the blocking nature should be clearly documented so callers know to construct it off the main thread.
Actual behavior
The constructor blocks on TCP connect; on a slow or unreachable server this hangs the UI thread long enough to trigger an Android ANR.
ElectrumClientconstructor performs blocking network I/O, causing ANR when called on UI threadSummary
uniffi_bdkffi_fn_constructor_electrumclient_newperforms a synchronous, blocking TCPconnect()during construction. When invoked from a platform main/UI thread (e.g. via flutter_rust_bridge / FFI on Android), this blocks the UI thread and produces an Application Not Responding (ANR).Environment
libbdk_dart_ffi.so)Severity
High. On Android, ANRs are tracked in Google Play's Android vitals. Apps that exceed Play's ANR rate threshold receive a "bad behavior" warning in the Play Console and can have their store visibility/discoverability reduced. A constructor that can hang the UI thread on a slow or unreachable Electrum server means any production app shipping bdk-ffi risks elevated ANR rates — making this a release-blocking issue for Flutter wallets in production.
Stack trace (main thread)
The main thread is parked inside
__connect— the network round-trip to the Electrum server runs synchronously on the UI thread.Expected behavior
Constructing an
ElectrumClientshould not block the calling thread on network I/O, or the blocking nature should be clearly documented so callers know to construct it off the main thread.Actual behavior
The constructor blocks on TCP connect; on a slow or unreachable server this hangs the UI thread long enough to trigger an Android ANR.