mirror of
https://github.com/MioMioOS/mio-plugin-music.git
synced 2026-06-11 03:44:31 +00:00
Symptom: installing v2.2.1 caused Mio Island to freeze ("卡崩") on launch.
Not a true crash, just the main runloop stuck long enough to trip the
"app not responding" state.
Root cause: MediaRemoteAdapterSource.spawn() scheduled bootstrapGet()
on `DispatchQueue.main.asyncAfter(+0.3)`. bootstrapGet runs a Perl
subprocess that dlopens MediaRemoteAdapter.framework then calls
`get` — that cold path takes 500ms to 1s in the worst case. During
that entire window, `proc.waitUntilExit()` blocks the main thread.
No UI events drain, SwiftUI drops frames, window looks hung.
Fix:
- Move the `DispatchQueue.main.asyncAfter` to
`DispatchQueue.global(qos: .userInitiated).asyncAfter` so the Perl
cold path runs on a background queue.
- Since `currentInfo` is now mutated from both queues (bg in bootstrap,
main in parseLine/stream), hop the merge + onUpdate back onto main
after we parse the JSON on bg. Single writer, no data race.
- parseLine is unchanged — still runs on main via the FileHandle
readabilityHandler hop.
Verified 30s alive, debug log shows bootstrap + stream rx both
emitting correctly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| AppleMusicAppleScript.swift | ||
| ChromeWebSource.swift | ||
| LyricsService.swift | ||
| MediaRemoteAdapterSource.swift | ||
| MediaRemoteSource.swift | ||
| SpotifyAppleScript.swift | ||