The left/right channels drifting randomly is one thing (SoundSource fixes it), but it gets worse..
I've been trying to raise awareness of Apples horrible audio issues for quite a few years now. Driver re-starts and USB re-connects, for no apparent reason. [0][1]
I have the issue on Mac Mini (2018) Intel, Mac Studio M1, Macbook Pro M2, so it's not device specific.
[0] https://developer.apple.com/forums/thread/132423
[1] https://news.ycombinator.com/item?id=32163114
[2] https://developer.apple.com/forums/search/?q=Popping+Sound
I have just reported a bug where high memory pressure could cause memory pages from the real-time audio thread to get swapped out, causing audio glitches. I am not hopeful for a timely resolution now...
I have this using Firefox on a 2019 Macbook Pro with 16GB RAM.
If the laptop has not been restarted for a while, Firefox tabs will eat up more and more memory over time until it makes the mac kind-of unresponsive (*) and will need to get hard power cycled.
The only signs that this is about to happen are two:
1. Any audio-emitting webapp will start to get very choppy, whether is youtube on FF, Google meet on chrome, or a slack call/huddle. Which is the problem I think you are referring to.
2. Switching workspaces animation will get very very choppy. Usually when this happens it's already almost too late.
(*) this means that while the pointer is still moving smoothily, even from a BT mouse, there is no reaction to any click or keyboard typing.
This seems unusual for such a serious memory leak to be present. Do you have any addons/plugins in Firefox? One of them may be the cause of the leak.
Uptime, 456 days 12 hours 8 minutes and 42 seconds. Firefox, 668 tabs. Countless other background tasks. Why doesn't my audio work!?!
That… is not a good idea. You should patch your OS.
That's not the original commenter. It's just someone being humorous.
Oh - sorry! I completely missed that. Will teach me for reading the comments at 7AM!
I see the same with firefox on my FreeBSD daily driver machine.
I thought it was because I pause the entire firefox process when the screen is locked. When it resumes it sometimes acts up (I use the STOP and CONT signals for this). But maybe it's just a FF bug.
I just restart it once every few days, my OS doesn't actually become unstable due to it. But i do have 64 GB of ram (one of the benefits to no longer being tied to apple's ecosystem is that memory upgrades and amazingly cheap)
I have the exact same issue, it starts to be choppy at random time and I have to reboot, usually in the middle of my work. I'm considering switching to another OS because of this single issue that has been there for years.
This is not fixable. You’d need an RTOS.
(You can’t mlock every single code page possibly executed by the thread for instance.)
How much memory could a single system thread handling the audio use? Forgive my ignorance I don't deeply understand OS level memory management but I thought, much like the task scheduler has priority understanding for CPU resource management, the memory manager had an idea of "these pages are important find some other page to evict".
About 25 megabytes for an approximately 10-second buffer.
I believe 96KHz/24bit is the highest quality audio supported natively on the MacBook Pro.
24 bits * 96KHz * 2 channels * 4x safety factor = 2.3 Megabytes per second.
It's not "use" but "ever potentially access", so it's unbounded unless they were careful. (Audio playback to speakers itself is bounded, but mixing isn't, and wireless headphones get complicated.)
It's difficult to know what the most important pages in memory are, because you'd have to observe every single memory access, and that's not worth the overhead.
Basically there's two ways it uses:
1. a program can tell the OS to keep something in memory (either by hinting it or forcing it, called mlock or wiring).
2. every so often, the OS will disconnect some pages such that accessing them faults (called "moving to the inactive queue"). If there's a fault, it know it's being used and moves it to active again. Eventually, if there aren't any for long enough, it gets to the end of the inactive queue and is paged out.
Why wouldn't it be possible to mlock all the memory pages used by the real-time thread?
I do my best to do it on the application side. It would be nice if Apple's CoreAudio did the same.
If you mean that it is difficult to identify the pages used, that is true, but I found a great way to do just that. I keep track of all the pages I mlock(), list all the remaining pages, and mprotect them to crash if I accidentally access memory that was not mlocked. That helped me identify a couple of pages I forgot, such as the one that contains the __stack_chk_guard
And regarding the code pages, for some reason I get a permission denied error if I try to mlock them. Not sure why.
There is no mlockall() on macOS, but if there was one, I could delegate the real-time audio handling code to a separate executable, and call mlockall(). I would be guaranteed all the pages used by the real-time thread would be mlocked.
And by the way if you are interested in the report I sent to Apple, you can find all the details with the sample code to reproduce the problem there:
https://twistedwave.com/AudioGlitches.zip
this is the fault of a poorly designed application and not the OS
Here is the contents of the bug I have reported with all the details and sample code to reproduce the problem:
https://twistedwave.com/AudioGlitches.zip
It contains a program where the only thing I do in the real-time callback is to count the glitches, and I made sure to mlock() the memory used by the glitch counting code. When the memory pressure increases, it glitches.
The point is to avoid the memory pressure from increasing. Have you investigated the allocation behaviour of ALL the code in your application?
The memory pressure is caused by other apps on the user's machine. My test program just increments a counter when there is a glitch, and requires a trivial amount of memory. Yet, it can see glitches when other apps run in the background allocating memory.
By any chance, is that problem related to the new Microsoft Teams and its incoming-call notification sound? Ever since the Sonoma update and the coinciding Teams switch it's glitching horribly.
Not for me. I have this problem and I have never used (or even installed) Teams.
I absolutely have this issue and would love to know more about any suspected causes.
Yup. I have found a strong correlation between memory pressure and audio glitches with my external dac. I filed a bug on this over two years ago and it has gotten no traction, but it sounds like you debugged it a bit more deeply than I did, so maybe yours will get noticed.
There might be something to it, higher than > 60% memory pressure and the issue will get a lot worse and more frequent.
I use an external DAC and encounter this crackling problem regularly. I have to unplug/replug my DAC to get it to go back to normal. I just thought it was a hardware problem with my DAC because it’s getting up there in the years, thought the caps might be going. Hmm…
I have 4 external all different sound cards and AMPs (USB), it's the same on all of them.
There is no software remedy, only re-connecting physically works (temporarily)
Well dang. I have had intention on buying a new DAC largely due to the issue; for better or worse there goes that plan.
I also didn't realize that this problem was common, but I switched to using an optical toslink cable to an external DAC which seems to have fixed it for me. Although now the system volume control doesn't work, but I can work around that with the volume control on my amp.
soundsource gives you the feature to control an external dac with the system volume. I bought it specifically for this use case.
I haven't tried Apple "certified" Thunderbolt devices yet, but others in the huge Apple thread [0] has and still experience cracks/pops.
“Amp” isn't an acronym
This is not a perfect solution, but if it's possible - see if the apps in question have an option for 'exclusive control' over the audio device.
If they do, then the app in question will pass the audio raw to the external device without the OS or any existing mixers interfering at all.
Of course, no other audio will play - only that from the app with exclusive control. It's not perfect but it can help in these scenarios.
I wonder if the clock source is getting out of whack with the DACs, it could be caused by extreme jitter.
Had crackling with slowdowns and kernel panics on M1.
Was fixed with a motherboard swap
Sometimes happens on Windows and Linux, too. Could be a bug in the XMOS SDK, seeing how almost all audio interfaces use it.
I had an external audio interface with occasional horrible bursts of white noise. I assumed it was the CPU not being fast enough, because there was a correlation between work and the bursts… but in the end it was a power supply that wasn’t powerful enough for all my hardware (although everything worked). I changed it, and the issue went away.
TIL! So far I'd been thinking that it was maybe an issue with my headphones (Bose QC45, connecting to the MBA M1)
I've been using Macs for audio work since 2007 and never experienced these issues. Currently using a Motu M4 but I've used probably a dozen audio interfaces plus the built-in ones.
Could this be an electrical issue?
Are you bus powering your interfaces?
Oh god, I thought my display was the problem, but it's the laptop! I'm so angry that Apple is to blame.
And get ready for macOS 14.4 where apparently Apple's decided that we're no longer allowed to kickstart coreaudiod (or any other LaunchDaemons)
I had crackling in my M1 MBP headphone jack, any variety of plugged in, USB/DAC all summer/early fall. I assumed it was an audio controller issue. And then it kind of dissipated, until there was a warm day in October. I had just watered the plant on my desk. All winter -- not an issue. House is cool and dry, but as soon as the humidity gets above 60% or so, I get crackling. Not sure what I'm going to do this summer.
I've definitely had the crackling on my M1 Ventura.
Also I use an old AudioBox USB and it sometimes dies and needs the unplug/replug.