Skip to content

High performance self-hosted photo and video management solution.

fix(mobile): background task crashing on Android (#12314)

Alexf26d47c8d958
diff --git a/mobile/android/app/src/main/kotlin/app/alextran/immich/BackupWorker.kt b/mobile/android/app/src/main/kotlin/app/alextran/immich/BackupWorker.kt
index 052a4e4c1f..c4c87ff519 100644
--- a/mobile/android/app/src/main/kotlin/app/alextran/immich/BackupWorker.kt
+++ b/mobile/android/app/src/main/kotlin/app/alextran/immich/BackupWorker.kt
@@ -118,7 +118,9 @@ class BackupWorker(ctx: Context, params: WorkerParameters) : ListenableWorker(ct
// called when the system has to stop this worker because constraints are
// no longer met or the system needs resources for more important tasks
Handler(Looper.getMainLooper()).postAtFrontOfQueue {
- backgroundChannel.invokeMethod("systemStop", null)
+ if (::backgroundChannel.isInitialized) {
+ backgroundChannel.invokeMethod("systemStop", null)
+ }
}
waitOnSetForegroundAsync()
// cannot await/get(block) on resolvableFuture as its already cancelled (would throw CancellationException)