Offline backlog blocks crash collection in other profiles
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
Research direction
The reproduction is a new test, ProfileCrashReportQueueTest.kt, which fills the approved folder of one profile via ReportLocator and then asserts that another profile can still collect, using the plugins' shouldStartCollecting. Run it first to confirm the failure. Done means the other profile collects while the offending profile stays limited, but the fix is unresolved: a per-profile cap may exceed the shared sender's batch limit, so the design needs maintainer input first.
Written by the indexing model from the issue text.
Description
Assisted-by: GPT-6.1-Terra xhigh & GPT-6.2-Sol high & GPT-6.2-Sol xhigh & GPT-6.2-Astra xhigh
Offline backlog blocks crash collection in other profiles [P2]
Subject: Offline backlog blocks crash collection in other profiles
Five unsent reports from one profile can prevent ACRA from collecting a new crash in another profile.
---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileCrashReportQueueTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileCrashReportQueueTest.kt
new file mode 100644
index 0000000000..6b2ae1cb86
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/multiprofile/ProfileCrashReportQueueTest.kt
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.multiprofile
+
+import android.app.Application
+import android.content.Context
+import androidx.core.content.pm.PackageInfoCompat
+import androidx.test.core.app.ApplicationProvider
+import com.ichi2.anki.acraCoreConfigBuilder
+import com.ichi2.anki.common.crashreporting.CrashReportService
+import com.ichi2.anki.initializeAcraCrashReporter
+import com.ichi2.testutils.EmptyApplication
+import com.ichi2.testutils.common.OS
+import io.mockk.every
+import io.mockk.mockkStatic
+import io.mockk.unmockkAll
+import org.acra.ACRA
+import org.acra.ACRAConstants
+import org.acra.ReportField
+import org.acra.builder.ReportBuilder
+import org.acra.config.CoreConfiguration
+import org.acra.config.CoreConfigurationBuilder
+import org.acra.config.LimiterConfiguration
+import org.acra.config.ReportingAdministrator
+import org.acra.data.CrashReportData
+import org.acra.file.CrashReportPersister
+import org.acra.file.ReportLocator
+import org.junit.After
+import org.junit.Assume.assumeFalse
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RobolectricTestRunner
+import org.robolectric.annotation.Config
+import java.io.File
+import java.text.SimpleDateFormat
+import java.util.Date
+import java.util.Locale
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
+
+@RunWith(RobolectricTestRunner::class)
+@Config(application = EmptyApplication::class)
+class ProfileCrashReportQueueTest {
+ @After
+ fun tearDown() {
+ unmockkAll()
+ }
+
+ @Test
+ fun `an offline backlog only limits the profile that collected it`() {
+ assumeFalse("ACRA's report file names contain ':', which Windows doesn't allow", OS.WINDOWS.isRunning())
+ val application = ApplicationProvider.getApplicationContext<Application>()
+ mockkStatic(ACRA::class)
+ every { ACRA.init(any<Application>(), any<CoreConfigurationBuilder>(), any()) } returns Unit
+ with(application) { initializeAcraCrashReporter() }
+ val config = CrashReportService.acraCoreConfigBuilder.build()
+ val offlineProfile =
+ ProfileContextWrapper.create(application, ProfileId("p_offline"), File(application.dataDir, "p_offline"))
+ val otherProfile =
+ ProfileContextWrapper.create(application, ProfileId("p_other"), File(application.dataDir, "p_other"))
+ val version = PackageInfoCompat.getLongVersionCode(application.packageManager.getPackageInfo(application.packageName, 0))
+ val timestamps = SimpleDateFormat(ACRAConstants.DATE_TIME_FORMAT_STRING, Locale.ENGLISH)
+ val approved = ReportLocator(offlineProfile).approvedFolder
+
+ // Reports that have been approved but could not be uploaded.
+ repeat(LimiterConfiguration().failedReportLimit) { index ->
+ val timestamp = timestamps.format(Date(index.toLong()))
+ val report =
+ CrashReportData().apply {
+ put(ReportField.APP_VERSION_CODE, version)
+ put(ReportField.FILE_PATH, offlineProfile.filesDir.absolutePath)
+ put(ReportField.USER_CRASH_DATE, timestamp)
+ }
+ CrashReportPersister().store(report, File(approved, timestamp + ACRAConstants.REPORTFILE_EXTENSION))
+ }
+
+ assertFalse(shouldCollect(offlineProfile, config), "A full queue must keep limiting its own profile")
+ assertTrue(shouldCollect(otherProfile, config), "Another profile's approved reports must not fill this profile's queue")
+ }
+
+ private fun shouldCollect(
+ profile: Context,
+ config: CoreConfiguration,
+ ): Boolean {
+ val report = ReportBuilder().exception(IllegalStateException("new crash"))
+ return config.pluginLoader.loadEnabled(config, ReportingAdministrator::class.java).all {
+ it.shouldStartCollecting(profile, config, report)
+ }
+ }
+}
Fix unresolved: no compatible temporary fix verified. A per-profile cap can exceed the shared sender’s batch limit and leave reports queued.
Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23337#pullrequestreview-6047733103, with a per-profile queue proposed in https://github.com/ankidroid/Anki-Android/pull/23337#issuecomment-7170891275
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 311
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ankidroid/Anki-Android#23806 ·
Maintainers usually reply within 1 day
-
code-scan
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
ankidroid/Anki-Android#23798 ·
Maintainers usually reply within 1 day
-
Send troubleshooting report does nothing with Never but says it was sentPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23797 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Browse rows that fail to load show as empty linesPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23786 · 1 comment ·
Maintainers usually reply within 1 day
-
The note editor's Cards button shows card type names as HTMLPossibly taken @rishithareddychalla claimed this today. Opencode-scan
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ankidroid/Anki-Android#23756 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Remove Collect againOpen
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
thisisartman/Meguri#211 ·
Maintainers usually reply within 1 day
-
follow-up
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Bug: Paused screen is never cleared, so spans and logs keep the previous fragment's screen nameOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
open-telemetry/opentelemetry-android#2309 ·
Maintainers usually reply within 1 day
-
📦 expo-location Android contributor: external needs review sdk-58 severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day