Skip to content

[Bug]: $Proxy4.uniffi_ldk_node_fn_free_node — TimeoutException on Node destroy (Play 2.2.0) #984

@piotr-iohk

Description

@piotr-iohk

What happened?

Google Play Console reports a production crash during LDK Node native teardown via UniFFI/JNA.

Play cluster label: Unknown Source - $Proxy4.uniffi_ldk_node_fn_free_node

Play report: https://play.google.com/console/u/1/developers/5690237613698939049/app/4973032799696771282/vitals/crashes/5d6157871f2b5f277ad8f0eeefefc2cf/details?days=60&isUserPerceived=true

Exception: java.util.concurrent.TimeoutException while calling uniffi_ldk_node_fn_free_node through JNA (Native.invokeVoid).

Call path: UniFFI pointer destroy / cleaner — Node$UniffiPointerDestroyer.destroyUniffiCleanerAction.run on FinalizerDaemon (not app main thread). Suggests Node is being freed by GC/finalizer while native free_node blocks too long or deadlocks.

Play Vitals (60-day window):

  • 4 events, 4 affected users.
  • Versions: mostly 181 (2.2.0) (~3), 180 (2.1.2) (~1).
  • Android: Android 16 Beta SDK 36 (~3), Android 15 SDK 35 (~1).
  • Devices: Pixel 9 Pro, Pixel 9, Motorola Edge 50 Pro, Samsung Galaxy S21 FE.
  • Visibility: 100% foreground.

Priority: Medium — lower than #980#982; separate from those clusters.

Expected behavior

  • Stopping or releasing the LDK Node must not crash the app.
  • Native node teardown (free_node) must complete within JNA timeout or be coordinated with explicit LightningService.stop() / LightningRepo.stop() so finalizer does not race active node use.

Steps to Reproduce

TBD — no deterministic repro. Suggested matrix:

  1. Android 15 or 16 device, mainnet wallet, notifications on (LightningNodeService / node running).
  2. Scenarios that stop or replace the node: background/foreground, notification Stop, FGS onTimeout ([Bug]: ForegroundServiceDidNotStopInTimeException on LightningNodeService (Android 15+, 2.2.0) #980), rapid wallet ops, memory pressure.
  3. Logcat: TimeoutException on uniffi_ldk_node_fn_free_node or FinalizerDaemon.
  4. Check whether Node references can be GC'd while node still running or during async lightningRepo.stop().

Logs / Screenshots / Recordings

Play Console: https://play.google.com/console/u/1/developers/5690237613698939049/app/4973032799696771282/vitals/crashes/5d6157871f2b5f277ad8f0eeefefc2cf/details?days=60&isUserPerceived=true

Full stack trace (most recent Play report):

Exception java.util.concurrent.TimeoutException:
  at com.sun.jna.Native.invokeVoid
  at com.sun.jna.Function.invoke (Function.java:418)
  at com.sun.jna.Function.invoke (Function.java:364)
  at com.sun.jna.Library$Handler.invoke (Library.java:270)
  at java.lang.reflect.Proxy.invoke (Proxy.java:1006)
  at $Proxy4.uniffi_ldk_node_fn_free_node (Unknown Source)
  at org.lightningdevkit.ldknode.Node$UniffiPointerDestroyer$destroy$lambda$1$$inlined$uniffiRustCall$1.invoke (ldk_node.android.kt:14367)
  at org.lightningdevkit.ldknode.Node$UniffiPointerDestroyer$destroy$lambda$1$$inlined$uniffiRustCall$1.invoke (ldk_node.android.kt:313)
  at org.lightningdevkit.ldknode.UniffiRustCallStatusHelper.withReference (ldk_node.android.kt:413)
  at org.lightningdevkit.ldknode.Node$UniffiPointerDestroyer.destroy (ldk_node.android.kt:14368)
  at org.lightningdevkit.ldknode.UniffiCleanerAction.run (ldk_node.android.kt:4595)
  at jdk.internal.ref.CleanerImpl$PhantomCleanableRef.performCleanup (CleanerImpl.java:212)
  at jdk.internal.ref.PhantomCleanable.clean (PhantomCleanable.java:133)
  at java.lang.Daemons$FinalizerDaemon.doClean (Daemons.java:407)
  at java.lang.Daemons$FinalizerDaemon.processReference (Daemons.java:377)
  at java.lang.Daemons$FinalizerDaemon.runInternal (Daemons.java:341)
  at java.lang.Daemons$Daemon.run (Daemons.java:135)
  at java.lang.Thread.run (Thread.java:1564)

Bitkit Version

2.2.0 (181) mostly, some 2.1.2 (180), mainnet to.bitkit. Native dep at v2.2.0 tag: ldk-node-android 0.7.0-rc.36.

Device / OS

Android 15 (SDK 35), Android 16 Beta (SDK 36). Pixel 9 / 9 Pro, Motorola lamu, Samsung r0s.

Reproducibility

Rarely (once or twice)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions