mozilla / cubeb

Cross platform audio library
ISC License
443 stars 127 forks source link

Clicks/pops glitch playing audio in Firefox when using ASIO audio interface #756

Open GrizzlyAK opened 1 year ago

GrizzlyAK commented 1 year ago

I've noticed that when playing audio streams (e.g., Soundcloud) or the samples in the Demos here , that I get clicking/popping or glitching occurring in a fairly regular pattern. I've been on Mozilla support and tried a host of troubleshooting suggested, leading to the discovery shown by about:support#media where the audio backend listed is WASAPI.

On the latest version of FF, on my Win10 machine, routing sound in Windows to my MOTU Audio Interface via ASIO at 48kHz is when this happens. Sound is not glitchy on YouTube, or most other video formats. It appears to be related to audio streaming only. What is interesting is that if I set the Windows Sound Control Panel to be 44.1kHz, the glitching stops, the sound plays clean (this requires a page refresh). If I set it back to 48kHz, it glitches again (after a page refresh). I first thought this to be a sample rate mismatch, but then found another app that had the same glitch issues. Further investigation into that app's settings revealede that the default settings was to use WASPI, even though it was still routed to my MOTU (now sure how that works, since it is ASIO - but I'm not real knowledgeable on Windows Audio). In that app, I was able to select ASIO instead of WASPI, set my MOTU device, choose 48kHz, and the sound in that app then played PERFECTLY!

What I gathered from that is that the issue is not with sample rate mismatch, but with using WASAPI with my ASIO MOTU audio interface. It appears that there is no way to change from WASAPI to ASIO in FF like there is with the other app mentioned.

Is there a reason for this? And can it be improved? I'm not sure exactly what in the WASAPI to MOTU signal chain that might be causing this glitching to occur, but it is remedied in other apps by utilizing the correct ASIO driver for the output device. Any advice would be appreciated.

padenot commented 1 year ago

I've noticed that when playing audio streams (e.g., Soundcloud) or the samples in the Demos here , that I get clicking/popping or glitching occurring in a fairly regular pattern. I've been on Mozilla support and tried a host of troubleshooting suggested, leading to the discovery shown by about:support#media where the audio backend listed is WASAPI.

Thanks for filing an issue!

Generally, when there's a problem in Firefox, it's best to open a bug in its tracker. If this happens in the future, https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=Audio%2FVideo%3A%20cubeb is a direct link that will place the ticket in the correct component. We receive an email here or there, so in the grand scheme of things we'll find it in either location, but cubeb is used by other programs than Firefox, so Firefox-specific issues are best directed to Firefox's own tracker.

I've opened https://bugzilla.mozilla.org/show_bug.cgi?id=1846409 for you, you can simply log in with your GitHub account. I've asked for a number of easy-to-gather information that will help us understand what is going on, please don't hesitate to ask if you have any question.

But in any case, I can answer some of your questions here -- but if possible, it would be best if we would discuss your issue with Firefox on bugzilla.

On the latest version of FF, on my Win10 machine, routing sound in Windows to my MOTU Audio Interface via ASIO at 48kHz is when this happens. Sound is not glitchy on YouTube, or most other video formats. It appears to be related to audio streaming only. What is interesting is that if I set the Windows Sound Control Panel to be 44.1kHz, the glitching stops, the sound plays clean (this requires a page refresh). If I set it back to 48kHz, it glitches again (after a page refresh). I first thought this to be a sample rate mismatch, but then found another app that had the same glitch issues. Further investigation into that app's settings revealede that the default settings was to use WASPI, even though it was still routed to my MOTU (now sure how that works, since it is ASIO - but I'm not real knowledgeable on Windows Audio). In that app, I was able to select ASIO instead of WASPI, set my MOTU device, choose 48kHz, and the sound in that app then played PERFECTLY!

When you say "on the latest version", does it mean it was working well before? Youtube and others use high-latency playback, optimized for robustness, whereas SoundCloud uses a very low latency API that is a bit more glitch prone (but it should generally work well -- I'm not saying there isn't a bug here). I think it must be related to sample-rate conversion somewhere in the chain, thanks for trying a couple of things out.

What I gathered from that is that the issue is not with sample rate mismatch, but with using WASAPI with my ASIO MOTU audio interface. It appears that there is no way to change from WASAPI to ASIO in FF like there is with the other app mentioned.

WASAPI is the native API to do audio input/output on Windows, and ASIO drivers are usually provided by audio equipment manufacturers. It's possible to use WASAPI to output to any sound card, but generally the playback will be more robust against high machine load (or allow achieving lower latency) if using ASIO. There's no general rule, but it's generally recommended to directly use ASIO drivers in music software (e.g. a Digital Audio Workstation, that kind of thing).

Is there a reason for this? And can it be improved? I'm not sure exactly what in the WASAPI to MOTU signal chain that might be causing this glitching to occur, but it is remedied in other apps by utilizing the correct ASIO driver for the output device. Any advice would be appreciated.

Unfortunately, the licence for the ASIO SDK is absolutely incompatible with the free software licence of Firefox. I wish we could use it, but as far as I know, we are not allowed to do so, for legal reasons. It might be possible to make a build of Firefox that can talk to an ASIO driver, but I don't think we'd be allowed to distribute it.

GrizzlyAK commented 1 year ago

Thanks for the response mate. Sorry, I posted the issue here because I understood this to be the audio code used in Firefox, and that it was maintained separately here. Didn't realize it was used by others, so it makes sense to go to FF. Thank you for filing the bug for me over there. I will follow up with them there.

As for latest version, no, it has never worked for me in FF since I can remember. It may be completely an issue with MOTU's interface with WASAPI, I don't know. SoundCloud never plays right for me. Always glitches. YouTube, never. Other web page audio streams are hit and miss. I guess I just assumed that any audio sent by windows would be through ASIO, but now realize that's not the case (since I have no way of setting that up in Windows CP as I do in my DAWs).

Didn't know about the ASIO SDK license, which is a problem it seems with all OSS. :-/ Come to think of it though, what about ASIO4ALL? Isn't that free? How do they get around it? So, for an application to talk to an ASIO driver, it requires a license? I thought that would be just for the driver manufacturers.

At any rate, given the continual frustration to get my Tabs back on bottom after seemingly every update to FF and Mozilla not seeming to care about user feedback, and now this, perhaps it's a good time to find another browser. I appreciate your help and feedback. I'll see what Mozilla has to say, but I'm not hopeful a fix is coming. Cheers.

padenot commented 1 year ago

Didn't know about the ASIO SDK license, which is a problem it seems with all OSS. :-/ Come to think of it though, what about ASIO4ALL? Isn't that free? How do they get around it? So, for an application to talk to an ASIO driver, it requires a license? I thought that would be just for the driver manufacturers.

ASIO4ALL isn't free software, as in this definition, it simply doesn't have a cost. To use the ASIO SDK, we'd have to sign an agreement with Steinberg, and all sorts of other things that would violate Firefox's free software licence. https://www.steinberg.net/developers/ has some info.

At any rate, given the continual frustration to get my Tabs back on bottom after seemingly every update to FF and Mozilla not seeming to care about user feedback, and now this, perhaps it's a good time to find another browser. I appreciate your help and feedback. I'll see what Mozilla has to say, but I'm not hopeful a fix is coming. Cheers.

Well, I'm a full time employee at Mozilla working on audio and video stuff, and I seem to care about your feedback, and if you get me the info we need in the other ticket, we can try to figure out what's up with your system. We have hundreds of millions of users that use Firefox, a fraction of which use professional sound cards every day without any problems (myself included), so surely something is off somewhere, but we can't figure out why without doing a bit of diagnosis.

That said, you do https://www.userchrome.org/how-create-userchrome-css.html and then put https://github.com/MrOtherGuy/firefox-csshacks/blob/master/chrome/tabs_on_bottom.css in the file userChrome.css, you'll have the tabs on the bottom like it used to be, it takes less than 5 minutes and works well.

GrizzlyAK commented 1 year ago

Agreed. Steinberg is the absolute worst. Recently bought Cubase Pro 12 and regret it now.

I also agree that you DO seem to care about this user. My sentiment comes after nearly two decades of using FF and being what feels like continually frustrated. Things break. Features disappear randomly. Requests ignored. And the general sentiment I see over and over in the forums that Mozilla devs have their own ideas about how things should be done and ignore the rest. I suspect there is some truth to that.

Anyway, I do rely on MrOtherGuy's efforts to keep up with the changes so that we can all continue to enjoy our tabs on the bottom. But that shouldn't be necessary simply because Mozilla chooses not to make this feature a user option, although it has been requested by many for years. So, you might imagine how we users feel that our needs/wants are being ignored.

Support on issues seems to be very good in my experience. It's just responsiveness to user needs/wants that seems lacking.

Please don't take my frustration the wrong way. I do appreciate all you folks do in making FF what it is, and despite the frustration, I do continue to use it for now. So there's that. ;-) Cheers.