Repository navigation
fix: keep the Sound details open and smooth when picking a device - #931
Conversation
The mixer listened on the main queue and read every process and device after each CoreAudio notification. A device switch sends a burst of them while coreaudiod answers slowly, which held the main thread for over a second and stalled the popup's animations. A QueueReader now reads on a queue of its own, once for a burst of changes, and hands the main queue only reads that changed. Refs #928
Setting the default device waits for coreaudiod to move every app's sound, up to about 90 ms while sound plays, and ran on the main thread. It now runs through runAction and BlockingWork, as volume and mute do. A device row in the Sound details now sends its device as a control's value, so the popup stays open as Control Center's does. Popups with selectOutputDeviceField blocks still follow dismissOnAction. Fixes #928
There was a problem hiding this comment.
All reported issues were addressed across 7 files
You’re at about 95% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack
Fix all with cubic | Re-trigger cubic
Before and after
340 unchanged screens
Visual review: 340 screens, none changed. |
Picking a device went through the widget's action, which refreshes the widget afterwards and so restarted the audio, microphone and Now Playing providers on the main thread while coreaudiod was still busy. Their listeners already follow the default device, so that action skips the refresh, as the direct switch did before.
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
## [0.20.0](v0.19.0...v0.20.0) (2026-11-29) ### Features * animate widgets that a profile shows or hides ([#948](#948)) by @M4n0x ([eec8544](eec8544)), closes [#947](#947) [#947](#947) * log quit causes and show unexpected quits in Status ([#953](#953)) by @M4n0x ([ea5a64e](ea5a64e)), closes [#952](#952) ### Bug Fixes * choose a submenu item opened from the App menus tray ([#944](#944)) by @MaHofseth ([add49b0](add49b0)), closes [#942](#942) * draw borders in whole pixels so they keep every edge on 1x screens ([#934](#934)) by @M4n0x ([8590fcd](8590fcd)), closes [#933](#933) [#933](#933) * keep a package version installed when its folder is hidden ([#962](#962)) by @M4n0x ([2d97d15](2d97d15)), closes [#961](#961) * keep the Sound details open and smooth when picking a device ([#931](#931)) by @M4n0x ([df96453](df96453)), closes [#928](#928) [#928](#928) * keep windows clear of the bar after a double-click fills them ([#936](#936)) by @M4n0x ([c1478d1](c1478d1)), closes [#935](#935) [#935](#935) * leave the keyboard with the app while StableBar shows its menus ([#943](#943)) by @MaHofseth ([abc1c4f](abc1c4f)), closes [#941](#941) * play an app's first sound at its mixer volume ([#899](#899)) by @M4n0x ([2c38350](2c38350)), closes [#897](#897) [#897](#897) * show a turned-off widget's last output when it comes back ([#950](#950)) by @M4n0x ([6776fcb](6776fcb)), closes [#949](#949) [#949](#949) * show Countdown and Join in Settings after picking it ([#940](#940)) by @MaHofseth ([6ecaa72](6ecaa72)) * stop offering a package update that is already installed ([#956](#956)) by @M4n0x ([4592ebc](4592ebc))
|
🎉 This PR is included in version 0.20.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Problem
In the Sound details, clicking an output or input device closed the popup, and its closing animation, and anything else animating on the bar, stalled for tens to hundreds of milliseconds. The card's other controls (volume, mute, an app's output menu) keep the popup open, and so does Control Center.
Fixes #928
Changes
AudioMixerreads CoreAudio off the main thread. It listened on.mainand ran a fullrefresh()for every notification: the PID, bundle ID and playing state of about 33 processes, then every device, each a round trip tocoreaudiod. A switch moves every app's sound to the new device, so it sends a burst of notifications whilecoreaudiodanswers slowly. The listeners, the per-process watching and the reads now live in a privateMixerReaderon a queue of its own. The main actor only hands what it reads toMixerState.MixerStateand the taps are unchanged.QueueReader(DataSource.swift, next toMainQueueRelay): reads on its own queue after a change, once for a burst of changes, and hands the main queue only reads that differ from the last.AudioMonitor.setDefaultDevicewaits untilcoreaudiodhas moved every app's sound: 72–86 ms in 4 of 10 tries while sound played.selectAudioDevicenow goes throughrunActionwith a newBlockAction.selectAudioDevice, so it runs inBlockingWork, after the widget's earlier actions, as volume and mute already do.["VALUE": id]), sodismissOnControlapplies, which is off by default. Popups withselectOutputDeviceFieldorselectInputDeviceFieldblocks still followdismissOnAction, asdocs/popups.mddescribes.docs/widgets.mdnow says picking a device leaves the popup open.runActionrefreshes a widget after its action, which for the Sound details stops and starts the audio, microphone and Now Playing providers, each with CoreAudio calls on the main thread. Their listeners already follow the default device, so.selectAudioDeviceskips that refresh, asmain's direct switch did. cubic pointed it out.No configuration change:
BlockActionisn't decoded, and the schema is unchanged.Testing
New tests in
DataSourceTests:aBurstOfChangesIsReadOnceOffTheMainThreadandaReaderSendsOnlyReadsThatChangeSomething. They failed (the type didn't exist) beforeQueueReaderwas added.Full suite: 1,458 Swift Testing and 293 XCTest tests. One run after the rebase had one failing Swift Testing test. I didn't keep its log, so I can't name it, and it didn't fail again in 3 more full runs.
swift build --build-tests,scripts/check.sh --quickandcommitlintpass. After the last commit,DataSourceTests,ProviderTests,BarEditingTestsand the popup tests (117) pass again.Measured in the app, macOS 27.2. An isolated dev copy (its own bundle ID, a scratch configuration, no mixer settings and no taps) had its Sound popup open. While a script closed the popup and switched the default output to a USB headset and back,
samplerecorded the main thread at 1 ms:mainAudioMixerAudioMixermainOn this branch the mixer's reads show up on the
StableBar.AudioMixerqueue instead. The only CoreAudio work left on the main thread isAudioMonitor's existing coalesced read (19 samples).Not checked by hand: clicking a device row in the running app. The switches above came from a separate process, so the popup staying open and the off-main switch are covered only by the build and the code path that volume and mute already use. The popup looks the same, so no before/after images; a recording of a click would show the change.
fix: play an app's first sound at its mixer volume #899 also changes
AudioMixer.swift, inperform. Now that fix: play an app's first sound at its mixer volume #899 is rebased ontomain, a trial merge of both branches has no conflicts.Merging
Three
fixcommits. A merge commit or a rebase merge keeps them all. To squash, keep thefix:title andFixes #928.Claude Opus 5.5 via Claude Code (T3 Code)