perf(reporting): move ReportStore initial scan off the main thread #296

Closed
opened 2026-07-04 06:46:37 +00:00 by JMR-dev · 0 comments
JMR-dev commented 2026-07-04 06:46:37 +00:00 (Migrated from github.com)

Phase-3 review finding (MEDIUM/perf). ReportStore eagerly does MutableStateFlow(scan()) in its constructor; scan() lists the debug_reports dir + reads + JSON-parses every file. It's an eager @Singleton dep of CrashReporter, whose install() runs on the main thread in Application.onCreate() — so every cold start does disk I/O + JSON parse on the main thread (StrictMode violation, ANR-adjacent, grows to the 30-day retention). Fix: make the initial scan lazy / on Dispatchers.IO (seed the flow empty, populate off-thread); install() only needs to write. Add a test.

Phase-3 review finding (MEDIUM/perf). `ReportStore` eagerly does `MutableStateFlow(scan())` in its constructor; `scan()` lists the debug_reports dir + reads + JSON-parses every file. It's an eager @Singleton dep of `CrashReporter`, whose `install()` runs on the **main thread** in `Application.onCreate()` — so every cold start does disk I/O + JSON parse on the main thread (StrictMode violation, ANR-adjacent, grows to the 30-day retention). **Fix:** make the initial scan lazy / on `Dispatchers.IO` (seed the flow empty, populate off-thread); `install()` only needs to write. Add a test.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: JMR-dev/LibreMail#296