Fix ExoPlayer wrong-thread crash + recordSearch off Main (perf-audit pass-2) — vc=79
All checks were successful
build-apk / build-and-publish (push) Successful in 7m11s
gitleaks / scan (push) Successful in 43s

- PlaybackService: the pauseOnHeadphoneDisconnect settings-watcher collector
  ran on globalScope (Dispatchers.IO) and called setHandleAudioBecomingNoisy
  on the ExoPlayer, which is thread-affine to the Main thread it was built on
  → latent IllegalStateException('Player accessed on the wrong thread') that
  fires every service start (the StateFlow emits on first subscription). Run
  the collector on Dispatchers.Main (mirrors resumePollJob).
- SearchViewModel: recordSearch (json-encode + SharedPrefs write) was on Main;
  wrap in withContext(Dispatchers.IO).

Both adversarially verified in the multi-agent perf audit (pass 2).
This commit is contained in:
Cobb 2026-06-21 05:04:39 -07:00
parent 2defbd2925
commit 96bad228ef
3 changed files with 19 additions and 4 deletions

View file

@ -9,6 +9,14 @@ const val STRAW_SDK_TARGET = 35
// Sulkta fork — Straw
//
// vc=79 / 0.1.0-CM — perf-audit pass-2 (app-side slam-dunks):
// * FIX a wrong-thread crash: the headphone-disconnect settings watcher
// ran on the IO scope and touched the ExoPlayer (thread-affine to the
// Main thread it was built on) → "Player accessed on the wrong thread"
// latent on every session. Collector now runs on Dispatchers.Main.
// * recordSearch (json-encode + SharedPrefs write) moved off the Main
// thread into withContext(Dispatchers.IO).
//
// vc=78 / 0.1.0-CL — perf-audit batch 1 (app-side):
// * Autoplay-next no longer drops the user's max-resolution cap. The
// enter-video track-selection reset built params from scratch, wiping
@ -100,6 +108,6 @@ const val STRAW_SDK_TARGET = 35
// vc=19 / 0.1.0-AE — rust pipeline cutover. Extraction via
// strawcore-core (Sulkta-Coop/strawcore) via the UniFFI wrapper; no
// NewPipeExtractor in the runtime path.
const val STRAW_VERSION_CODE = 78
const val STRAW_VERSION_NAME = "0.1.0-CL"
const val STRAW_VERSION_CODE = 79
const val STRAW_VERSION_NAME = "0.1.0-CM"
const val STRAW_APPLICATION_ID = "com.sulkta.straw"