Skip to content

fix(audio): reliable mute for bare executables and multiple app instances - #488

Open
ron1196 wants to merge 3 commits into
ronitsingh10:mainfrom
ron1196:fix/bare-executable-mute-upstream
Open

ron1196 wants to merge 3 commits into
ronitsingh10:mainfrom
ron1196:fix/bare-executable-mute-upstream

Conversation

@ron1196

@ron1196 ron1196 commented Nov 6, 2026

Copy link
Copy Markdown

Problem

Apps launched as bare executables (no .app bundle — e.g. a game or tool built from source and run from a terminal) could not be reliably muted:

  • Every such process showed up as a blank row (no name).
  • Mute/volume clicks on those rows were erratic: rows swapped state, unmute didn't work, and audio kept playing from processes whose row showed muted.

Reproduced with several instances of the same SDL game binary running at once (plus a second binary), all muted in FineTune, still audible.

Root causes

  1. Empty bundle ID treated as a real value. Core Audio's kAudioProcessPropertyBundleID returns "" (not nil) for bare executables. AudioProcessMonitor used it as-is, so the row name became "".components(separatedBy: ".").last == "", and persistenceIdentifier (bundleID ?? "name:…") became "" for every bare executable — they all shared one settings key.

  2. Duplicate SwiftUI row IDs. DisplayableApp.id was persistenceIdentifier. Multiple running instances of the same executable (or the same app launched twice) share that identifier, so ForEach got duplicate IDs. SwiftUI then mixes rows up: a click on one row can mute/unmute a different process, and the process actually playing stays unmuted while its row looks muted.

  3. Muted taps were excluded from the health monitor. startHealthMonitor skipped muted taps on the assumption that muted taps get no IO callbacks. They do (_lastRenderHostTime is updated before the mute early-return), and .mutedWhenTapped only silences the process while the tap is being read — so a muted tap that died was never recreated and the app's original audio leaked through indefinitely.

  4. setMute could be a silent no-op. Unlike setVolume, setMute didn't ensure a tap exists. If tap creation had failed earlier, the row showed muted while nothing was silencing the app.

Changes

  • AudioProcessMonitor: treat an empty bundle ID as missing. Name fallback order: resolved app name → last bundle-ID component → NSRunningApplication.localizedName → executable name (proc_pidpath) → "Unknown". Bare executables now get a real name, icon, and a name:<executable> persistence key.
  • AudioApp.rowID (persistenceIdentifier#pid) is used as DisplayableApp.id for active rows, so rows are unique per process. Saved settings remain keyed by persistenceIdentifier. Keyboard navigation resolves rows by the new ID and ignores a row whose process exited (instead of writing a junk settings key).
  • Health monitor now checks muted taps too.
  • setMute ensures the tap exists before applying mute.

Per-row mute/volume behavior is unchanged: each instance is still controlled from its own row.

Tests

  • AudioProcessMonitorIdentityTests: empty-bundle-ID handling, name fallback order, distinct persistence key for bare executables, and distinct row IDs for multiple instances sharing one persistence key.
  • Existing PopupKeyboardNavModelTests updated for the renamed row-ID label.
  • Full build and test suite pass in CI on macOS 26 / Xcode 26.6.

Manually verified: bare executables show named rows, each row controls its own process, and pausing each game process in turn while listening confirmed no audio leaks after a fresh launch.

🤖 Generated with Claude Code

ronm-cye and others added 3 commits November 6, 2026 14:32
Core Audio reports an empty bundle ID ("") for processes without an
app bundle. FineTune used it as-is, so every such process got a blank
row and shared the "" persistence key, colliding volume/mute settings.
Treat "" as missing and name the app after its executable.

The tap health monitor also skipped muted taps, assuming they get no
callbacks. They do, and .mutedWhenTapped only silences the process
while the tap is read, so a dead muted tap leaked audio forever.
Health-check muted taps too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DisplayableApp.id was the persistence identifier, which every running
instance of the same executable (or app) shares. SwiftUI rows with
duplicate IDs swap state, so mute/volume clicks landed on the wrong
process and the one actually playing stayed unmuted.

Active rows now use persistenceIdentifier#pid; saved settings stay keyed
by persistenceIdentifier. Keyboard navigation resolves rows by the new
ID and ignores rows whose process exited instead of writing a junk key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setMute only flipped the flag on an existing tap. If tap creation had
failed earlier, the row showed "muted" while the app kept playing.
Ensure the tap exists first, as setVolume already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ron1196 ron1196 changed the title fix: reliable mute for bare executables and multiple app instances fix(audio): reliable mute for bare executables and multiple app instances Nov 6, 2026
@ron1196

ron1196 commented Nov 13, 2026

Copy link
Copy Markdown
Author

@ronitsingh10 Muted bare executables (no .app) and multiple instances of one app kept playing: empty bundle IDs gave blank rows sharing one settings key, and duplicate row IDs sent mute clicks to the wrong process. This PR names them by executable, gives each process a unique row, and fixes two related tap gaps. Passes CI on my fork. Could you take a look?

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.

2 participants