From 6def355b6ed7be600aae7c1e5ff13c2e78c45e17 Mon Sep 17 00:00:00 2001 From: Jorge Martin Espinosa Date: Tue, 25 Jun 2024 11:26:18 +0200 Subject: [PATCH] Use IO dispatcher for cleanup in bug reporter (#3092) --- changelog.d/3086.bugfix | 1 + .../rageshake/impl/reporter/DefaultBugReporter.kt | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelog.d/3086.bugfix diff --git a/changelog.d/3086.bugfix b/changelog.d/3086.bugfix new file mode 100644 index 0000000000..da39ba616f --- /dev/null +++ b/changelog.d/3086.bugfix @@ -0,0 +1 @@ +Make sure we don't use the main dispatcher while closing the bug report request, as it can lead to crashes in strict mode. diff --git a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt index 9e89ff9a76..f9f8d7e5b9 100755 --- a/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt +++ b/features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt @@ -282,11 +282,13 @@ class DefaultBugReporter @Inject constructor( listener.onUploadFailed(serverError) } } finally { - // delete the generated files when the bug report process has finished - for (file in bugReportFiles) { - file.safeDelete() + withContext(coroutineDispatchers.io) { + // delete the generated files when the bug report process has finished + for (file in bugReportFiles) { + file.safeDelete() + } + response?.close() } - response?.close() } }