Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/src/main/java/to/bitkit/services/LightningService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ class LightningService internal constructor(
}
this@LightningService.node = null
}
// Releasing a node whose stop left tasks detached shuts down its tokio runtime under them, and the first
// one to resume (a VSS write returning, or a thaw from the freezer) aborts the app with "A Tokio 1.x
// context was found, but it is being shutdown." In the background, kill the process while the runtime
// is alive instead; a cold start restores everything. In the foreground, release as before.
// A stop can leave tasks detached, e.g. a VSS write that keeps retrying. ldk-node keeps their runtime
// alive until they end, but the release returns before that, so a rebuilt node could run while the old
Comment thread
ovitrif marked this conversation as resolved.
Resolved
// node's work still writes. In the background, kill the process instead; a cold start restores
// everything. In the foreground, release as before.
if (monitor.hasDetachedWork && isAppInBackground() && exitBeforeRuntimeShutdown()) return@withContext
releaseHandle(node)
Logger.info("Node stopped", context = TAG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ class LightningServiceTest : BaseUnitTest() {
assertNull(sut.node)
}

// Regression #1536: releasing the node shuts down its runtime under the detached tasks, which abort the app
// #1536: in the background, a node with detached work is not released, so its work cannot overlap a rebuilt node
@Test
fun `stop exits the process instead of releasing a node with detached work in background`() = test {
isAppInBackground = true
Expand Down
2 changes: 1 addition & 1 deletion changelog.d/next/1536.fixed.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fix a rare crash when the Lightning node was slow to stop while Bitkit was in the background.
Fixed a rare crash when the Lightning node stops while background work is still running.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "k
ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ldk-node-android = { module = "com.synonym:ldk-node-android", version = "0.7.0-rc.80" }
ldk-node-android = { module = "com.synonym:ldk-node-android", version = "0.7.0-rc.81" }
lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycle" }
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
Expand Down
11 changes: 11 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4406,6 +4406,17 @@
<sha256 value="526f392bd7abc19546ca2a0954c3e79366fbc6becf8869f1ff21b52296d7bc66" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.synonym" name="ldk-node-android" version="0.7.0-rc.81">
<artifact name="ldk-node-android-0.7.0-rc.81-native-debug-symbols.zip">
<sha256 value="3aefaf5b3ea156ed55fb76d6adb4c0b3dcf1bc566102cd02a1b0b5713eed26b7" origin="Generated by Gradle"/>
</artifact>
<artifact name="ldk-node-android-0.7.0-rc.81.aar">
<sha256 value="04d03d0ecd298f8a7ec238037b62247d3b1bba9640af1018ba26639a8305a352" origin="Generated by Gradle"/>
</artifact>
<artifact name="ldk-node-android-0.7.0-rc.81.module">
<sha256 value="eab2c77701542ee43ad631d5796ef63cbc4661f861ef25a35f7336e475c6936f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.synonym" name="paykit-android" version="0.1.1-rc8">
<artifact name="paykit-android-0.1.1-rc8-native-debug-symbols.zip">
<sha256 value="a876e5ca61b8c2bac6166460906e561090f5f1f39995d751fbe9c8cc99b18a1e" origin="Generated by Gradle"/>
Expand Down
Loading