From f26d47c8d95827a20f3fe4cfe0f64302bf8ab645 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 4 Sep 2024 22:39:50 -0500 Subject: [PATCH] fix(mobile): background task crashing on Android (#12314) --- .../app/src/main/kotlin/app/alextran/immich/BackupWorker.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)