Skip to content

fix(audio): gate RunningBoard background-audio suspend on active libsimaudio stream - #19

Merged
Apdelrahman1911 merged 1 commit into
mainfrom
fix/rb-audio-active-gating
Dec 6, 2026
Merged

Apdelrahman1911 merged 1 commit into
mainfrom
fix/rb-audio-active-gating

Conversation

@Apdelrahman1911

Copy link
Copy Markdown

Root Cause

host/simshim/compat/simshim.c (shim_rb_audio) unconditionally returned NO at -[RBProcess _lock_suspend] so idle UIBackgroundModes:["audio"] apps (Maps, Health) would be suspended and reclaimable by jetsam. However, because x86Sim does not boot mediaserverd (audio goes via libsimaudio.dylib directly to x86sim-ctl simaudio), actively playing background-audio apps hold no mediaserverd RunningBoard assertion and were immediately suspended on app.background.

Fix

  • host/simaudio/simaudio.c: acquire a SIGKILL-safe advisory flock(LOCK_EX | LOCK_NB) on <state>/simaudio-out-bundle/<bundle_id>.lock (strictly allowlisted bundle characters) during active output dev_start() -> dev_stop().
  • host/simshim/compat/simshim.c: in shim_rb_audio(), check whether <state>/simaudio-out-bundle/<bundle_id>.lock is actively locked; return YES while an output stream is playing and continue returning NO once playback stops or the process exits.

Verification

  • Native ci.yml (rust-launcher-tests, rust-mtlvk-tests, web, build / appimage) on this PR, plus Ubuntu mac-build-arm64-shims.sh simaudio simshim cross-compile verification.

…ound-audio apps

Previously shim_rb_audio() in host/simshim/compat/simshim.c unconditionally
returned NO to runningboardd at -[RBProcess _lock_suspend]. Because x86Sim does
not run mediaserverd (libsimaudio.dylib interposes CoreAudio HAL directly),
runningboardd suspended UIBackgroundModes:["audio"] apps immediately upon
backgrounding even while audio was actively playing.

Have libsimaudio.dylib hold a SIGKILL-safe advisory flock on
<state>/simaudio-out-bundle/<bundle_id>.lock while an output IO stream is active
(dev_start -> dev_stop), and have shim_rb_audio() return YES when that lock is
held while still returning NO to suspend idle background-audio apps (Maps,
Health) once playback stops or after process exit.
@Apdelrahman1911
Apdelrahman1911 merged commit 292b523 into main Dec 6, 2026
4 checks passed
@Apdelrahman1911
Apdelrahman1911 deleted the fix/rb-audio-active-gating branch December 6, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant