Volume does not stay where it is manually set using pulseaudio
Categories
(Core :: Audio/Video: cubeb, defect, P3)
Tracking
()
People
(Reporter: crazylegoguy, Assigned: padenot)
References
Details
Attachments
(2 files)
Updated•8 years ago
|
Reporter | ||
Comment 2•8 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
Comment 3•8 years ago
|
||
Comment 4•7 years ago
|
||
I can confirm this bug on my Arch Linux distro. As stated here (https://bbs.archlinux.org/viewtopic.php?id=244401) Firefox synchronizes HTML5 player volume level on its Pulseaudio sink (AudioIPC Server), therefore changes of volume level inside the player are reflected on AudioIPC Server and these are visible in the mixer (Kmix or pavucontrol). But if the user changes volume from the mixer affecting AudioIPC Server sink, the modifications are not reflected inside the HTML 5 player.
I think this is a design issue. If you want to synchronize player volume with pulseaudio sink related to Firefox, you should do it both way, not only one. Besides, this causes other issues when PulseEffect is running. At this point I prefer Chromium behavior: volume is not synchronized, I can set volume level inside the mixer manually and it is stored across sessions.
I tried this on Windows and the synchronization is missing, so it seems a bug only related to Pulseaudio on Linux.
And, please, change name, AudioIPC Server is not friendly. If I see "Chromium playback" for Chromium, I'd like to see "Firefox playback" for Firefox.
Comment 6•6 years ago
|
||
I confirm that volume of one of "AudioIPC Server" available in my PulseAudio list, sometimes turns to 75% or 79% when I listen to Youtube videos.
firefox-67.0-4.fc30.x86_64
Fedora 30 KDE with Pulseaudio flat volumes off
I confirm that sort of behaviour on firefox 74.0 and Pulseaudio 13.
Sometimes volume on new playback tab is set to something between 75% and 90% even tho I've always set "Firefox Audio Stream" volume to 100%
Volume is not synchronized with HTML5 player as it is also set on 100% volume
On top of that why every single tab shows up as new "device" in the volume mixer? That's ridiculous, no other app exhibits that behaviour and no other sane app changes its own mixer volume
Comment 9•5 years ago
|
||
It's not just that it ignores volume set externally, it's that it defaults to full 100% volume each time you open a new page with a multimedia object in it, (and possibly enable sound if "Block websites from automatically playing sound" isn't set)
At least with mine, if I open a facebook or youtube video, the player is initially in mute state, and I have to unmute it by clicking on the volume icon (annoying by itself, since if I just went to a media player, why wouldn't I want the sound to play? But the alternative is scrolling down a page and some idiot sets up an autoplay ad and I get blasted with their inane drivel). Once unmuted, I have the full 85dB of sound playing through my speakers 2 feet behind my head. I then slam the pause button and move the system volume control down, then focus back on the player, press play, and firefox helpfully sets it back up to 100%!
Why can't Firefox just be like every other damn browser out there, and not fiddle with the volume without my consent? I am confused as to why so many more people don't consider this a showstopped. I just finally got sick of how awful Chrome has become recently, but this is unusable nonsense. I don't want to have to go back to the bad old days of maintaining two browsers just so one can competently play audio.
Meanwhile, in reply to Fahrradkette from comment #4:
For me I hacked a workaround https://pastebin.com/WVjnS00T which creates a
null device to be the sink for Firefox. Basically it ignores Firefox's
volume settings (or rather expects it to be at 100%) and lets me set it in
pavucontrol only.
Does this still work? From reading the code, I don't understand how this hooks into pulseaudio and/or firefox, and it doesn't seem to do anything other than fire up pavucontrol with no apparent modifications to the streams.
Comment 10•5 years ago
|
||
I think the root cause is that our audio backend does not expose an API to retrieve the current volume level so we default it to 100% every time a new media element is created. We should change that. In the meantime can you please experiment with media.default_volume
in about:config
. It must change that default level to whatever you like. Please let us know how it works, I haven't tried it myself.
Assignee | ||
Comment 11•5 years ago
|
||
No it's because we open an audio stream per process, we have multiple processes and we use server side volume handling that doesn't work the way people expect it to, that interacts badly with websites setting volumes to 1.0.
I'm tired of hearing about this, I'll remove this altogether.
Comment 12•5 years ago
|
||
I always thought this behaviour is meaningless. See here.
Removing this is the best thing you can do, behaving like every other browser on the planet.
Comment 13•5 years ago
|
||
The fix is here
Updated•5 years ago
|
Comment 14•5 years ago
|
||
crazylegoguy,
the fix is landed in bug 1631448. Would you mind checking if this is fixed in Firefox Nightly?
Assignee | ||
Comment 15•5 years ago
•
|
||
Same for other reporters that can repro, can you check in latest Nightly ? The tarball can be decompressed, ran directly and deleted.
By default, this happens on non-debian-based system I think, although you can configure a debian-based system to repro.
Assignee | ||
Comment 16•5 years ago
|
||
We had to back this out, because apparently pulse now set all Nightly processes to 0% volume we we remove the calls to the volume pulse API, which didn't really expect. We'll investigate and reland next cycle.
Comment 17•5 years ago
|
||
Which is your plan? Only disabling synchronization of volume on pulse sink or also making Firefox using a single pulse sink instead of one per each tab?
I'd like both.
Comment 18•5 years ago
|
||
Still happening in latest releases...
Having to manually readjust the volume in every YouTube video (and some other sites) by doing just about anything (rewinding, pausing/playing, setting volume via arrow keys) is starting to become really annoying.
Comment 19•5 years ago
|
||
I stumbled upon this bug after constant annoyance while skipping through songs in YouTube Music. In reference to the Python script posted earlier, I figured I'd post a raw command line version which will achieve I believe more or less the same thing for folks should they want to isolate Firefox to a virtual sink which can then be controlled independently from a new loopback source:
$ pactl list short sinks
4 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
$ pacmd load-module module-null-sink sink_name=virtual
$ pacmd load-module module-loopback source=virtual.monitor sink=alsa_output.pci-0000_00_1b.0.analog-stereo
$ pactl list short sinks
4 alsa_output.pci-0000_00_1b.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
5 virtual module-null-sink.c s16le 2ch 44100Hz RUNNING
At this point, I have a separate "Null Output" sink available in pavucontrol which I can use for Firefox instead of my normal "Built-in Audio Analog Stereo" sink. And if I select "All Streams" on the Playback tab, I then also see my loopback source now which I can keep at my desired volume without worry of it being reset by Firefox.
Hope that helps others.
Comment 20•5 years ago
|
||
Thank You @nipsy ! This worked great for me :)
To state the obvious, make sure you use your device name for the sink in the 3rd command... yes I made this mistake :)
Comment 21•5 years ago
|
||
(In reply to richard.logwood from comment #20)
Thank You @nipsy ! This worked great for me :)
To state the obvious, make sure you use your device name for the sink in the 3rd command... yes I made this mistake :)
Update: I'm having very mixed success with this and will default to using Chrome for audio feeds (which works ok) until this bug gets resolved.
Comment 22•5 years ago
|
||
In my case, the default PA volume depends on the media. For example, Angel -- Massive Attack loads at 91% (-2.45dB). Setting the tab volume in pavucontrol to 100%, then hitting the left arrow while playing removes the AudioStream row from pavucontrol before its volume is reset to 91%.
Tested on FF Nightly 81.0a1 (2020-08-11) (64-bit).
Comment 23•5 years ago
|
||
The null output loopback workaround is working for me, or it at least lets me adjust the overall volume of Firefox when needed. The sink-input still gets reset to whatever random volume Firefox feels like all the time though.
Comment 24•5 years ago
|
||
I confirm the bug and that this is excruciating - however I much prefer Firefox over any other browser, and I'd like to give all the devs and the project a big hug. Looking forward to the fix making it to stable-branch.
Comment 25•5 years ago
|
||
Another way to trigger the problem is:
- open a youtube video
- low the volume from pulse audio, to let's say, 50%
- change the quality of the youtube video in youtube video settings
- you will get the audio level in pulse audio back to 100%
Comment 26•5 years ago
|
||
I confirm the bug on my PulseAudio Arch Linux system.
@Germano Massullo
This is right. I can relate.
Comment 27•5 years ago
|
||
I can only confirm this annoying behaviour on KDE Neon 5.20.4 (based on Ubuntu Focal Fossa 20.04).
When listening to music playlists on YouTube, the volume is inadvertently reduced to an arbitrary value (depending on the media) each time a new clip starts playing.
The virtual sink is useless for me because it would only allow to further reduce the volume, but I just want it to stay at 100%.
Please fix this in stable and esr as soon as possible, this bug has been around for way too long.
Comment 28•5 years ago
|
||
Repro with Firefox 84.0 on Arch Linux. A mitigation that works for me is to tweak the media.volume_scale
option in about:config
.
Comment 29•5 years ago
|
||
(In reply to Sinkerine from comment #28)
Repro with Firefox 84.0 on Arch Linux. A mitigation that works for me is to tweak the
media.volume_scale
option inabout:config
.
Again, changing the volume scale in about:config
only helps if you want to decrease the volume, but if you need it stay at full level that's useless...
Comment 30•5 years ago
|
||
(In reply to acebone from comment #24)
I confirm the bug and that this is excruciating - however I much prefer Firefox over any other browser, and I'd like to give all the devs and the project a big hug. Looking forward to the fix making it to stable-branch.
I can only agree. I like Firefox for its customisability and am very used to it, but this bug is troubling me.
Comment 31•5 years ago
|
||
(In reply to Manuel GeiΓer from comment #27)
I can only confirm this annoying behaviour on KDE Neon 5.20.4 (based on Ubuntu Focal Fossa 20.04).
When listening to music playlists on YouTube, the volume is inadvertently reduced to an arbitrary value (depending on the media) each time a new clip starts playing.
The virtual sink is useless for me because it would only allow to further reduce the volume, but I just want it to stay at 100%.
Please fix this in stable and esr as soon as possible, this bug has been around for way too long.
They won't fix it because they are busy on something else, don't have time, neither any clue on how to work on it. Someone already tried in the past and failed breaking all the audio stack.
Recently this became not a big issue to me because I switched to a Chromium-based browser and when I was using Firefox I set PulseEffects with this preset which is leveling the volume to the max whichever thing Firefox does and it works also as loudness equalizer for other applications.
It works only for PulseAudio, not Pipewire, at least until PulseEffects will have official Pipewire support.
Comment 32•5 years ago
|
||
(In reply to kurmikon from comment #31)
They won't fix it because they are busy on something else, don't have time, neither any clue on how to work on it. Someone already tried in the past and failed breaking all the audio stack.
Yeah, I know... The problem is just: this issue affects many, many users, as the vast majority of distributions ship with Pulse as audio system and Firefox as default browser.
I don't understand why PulseAudio at all permits applications to change their own volume in the system mixer. The mixer should be for the user to set volumes of different applications into proportions, and apps should never be able to change what the user has defined, I think. What was the original idea behind this? Why was this implemented?
Recently this became not a big issue to me because I switched to a Chromium-based browser and when I was using Firefox I set PulseEffects with this preset which is leveling the volume to the max whichever thing Firefox does and it works also as loudness equalizer for other applications.
It works only for PulseAudio, not Pipewire, at least until PulseEffects will have official Pipewire support.
Somehow making PulseAudio force Firefox to stay at 100% is what I am looking for, but this equalizer yet doesn't seem to fit because it affects all other applications as well.
Comment 33•5 years ago
|
||
(In reply to Manuel GeiΓer from comment #32)
Yeah, I know... The problem is just: this issue affects many, many users, as the vast majority of distributions ship with Pulse as audio system and Firefox as default browser.
I don't understand why PulseAudio at all permits applications to change their own volume in the system mixer. The mixer should be for the user to set volumes of different applications into proportions, and apps should never be able to change what the user has defined, I think. What was the original idea behind this? Why was this implemented?
I don't have idea, but it's not a PulseAudio issue since it's not happening in other browsers, neither in other applications. The future multimedia pipeline on Linux will be Pipewire (Arch Linux already adopted it), I wonder if this would happen in the case Firefox supports it directly.
Somehow making PulseAudio force Firefox to stay at 100% is what I am looking for, but this equalizer yet doesn't seem to fit because it affects all other applications as well.
You can disable the "Process All Output" option and enable only Firefox.
Comment 34•5 years ago
|
||
I think I have finally found a good workaround for me: The extension enhanced-h264ify (https://github.com/alextrv/enhanced-h264ify) has an option to disable the YouTube html5 loudness normalization.
Comment 35•5 years ago
|
||
(In reply to Manuel GeiΓer from comment #34)
I think I have finally found a good workaround for me: The extension enhanced-h264ify (https://github.com/alextrv/enhanced-h264ify) has an option to disable the YouTube html5 loudness normalization.
Yes, I can confirm the extension enhanced-h264ify is working for me as well. It is helpful with hardware acceleration too. Thanks!
Comment 36•5 years ago
|
||
TR;DR
This is a Youtube-specific feature meant to normalize the volume of different videos to the same perceived (peak) loudness. But this, coupled to some weirdness in Firefox's PulseAudio backend, results in YouTube's JavaScript code changing the PulseAudio mixer (sink) value, instead of some other volume level that should stay hidden inside the process. So if the user herself tweaks the PulseAudio sink volume from the OS mixer, it invariably gets reset the next time the Youtube script performs a seek or a quality change or anything else.
For now the enhanced-h264ify extension is a good way to block this specific offending script on Youtube. But IMHO Firefox should decouple the HTML5 volume setting from the PulseAudio sink volume, as :padenot tried doing before.
By the way, I think Firefox should keep using a separate PA sink per process / tab, as it does now, because this makes it easier to control or redirect the audio coming from different websites, which is useful for a variety of reasons. Chrome seems to be doing the same as well, so IMHO this "multiple sink" aspect should not be changed.
Comment 37•5 years ago
|
||
(In reply to Tobia from comment #36)
TR;DR
This is a Youtube-specific feature meant to normalize the volume of different videos to the same perceived (peak) loudness. But this, coupled to some weirdness in Firefox's PulseAudio backend, results in YouTube's JavaScript code changing the PulseAudio mixer (sink) value, instead of some other volume level that should stay hidden inside the process. So if the user herself tweaks the PulseAudio sink volume from the OS mixer, it invariably gets reset the next time the Youtube script performs a seek or a quality change or anything else.
There may also be other websites using HTML5 volume control, so the issue does not only affect YouTube and hence enanced-h264ify is not a full fix. Also, it seems like YouTube's new login "wall" (see https://github.com/yourduskquibbles/webannoyances/issues/245
), which is shown in some countries, breaks the mechanism to disable volume normalisation.
For now the enhanced-h264ify extension is a good way to block this specific offending script on Youtube. But IMHO Firefox should decouple the HTML5 volume setting from the PulseAudio sink volume, as :padenot tried doing before.
By the way, I think Firefox should keep using a separate PA sink per process / tab, as it does now, because this makes it easier to control or redirect the audio coming from different websites, which is useful for a variety of reasons. Chrome seems to be doing the same as well, so IMHO this "multiple sink" aspect should not be changed.
I disagree about that - I think my Chromium (beta branch) doesn't do that, and this behaviour is more annoying than helpful for most users. Consider one wants to quickly and safely turn off audio for the entire Firefox application, then it is tedious to go through all seperate sinks and mute each of them. I can understand that controlling the volume for different tabs seperately may be useful for some rare conditions, but that's not what is commonly needed/wanted. It may also spam your system mixer if you have many tabs open.
If this feature is desired, then I think it should rather be implemented client-side in Firefox, maybe with some about:volume page. Also I'd like to note that Firefox does not do this on Windows or macos, and there is no point at handling it different on one platform.
Overall, I have to say that Firefox on Linux is a very disappointing experience, it seems like no one really cares about it due to the rather small number of users compared to the two proprietary platforms.
Comment 38•5 years ago
|
||
By the way, I think Firefox should keep using a separate PA sink per process / tab, as it does now, because this makes it easier to control or redirect the audio coming from different websites, which is useful for a variety of reasons
Getting 20 "Firefox: Audio Sink" on mixer list doesn't make anything easier
PA sink per window or per anonymous session would make much more sense from user perspective if you want more detailed control, especially if sinks will be named in recognizable way and not just "Audio sink".
Comment 39•5 years ago
|
||
Yeah, these issues used to happen with me every time as the volume didn't stay where it was set manually, but then I ordered an amp for guitar from an online store using their positive grid coupons and I got an amplifier, and the volume issue solved in one go at an affordable rate.
Comment 40•4 years ago
|
||
I've reproduced the bug with Firefox version 88.0 on Lubuntu.
Comment 41•4 years ago
|
||
(In reply to Tobia from comment #36)
But this, coupled to some weirdness in Firefox's PulseAudio backend, results in YouTube's JavaScript code changing the PulseAudio mixer (sink) value, instead of some other volume level that should stay hidden inside the process.
This is precisely correct. It is a design error to have firefox adjusting the PulseAudio stream volume, ever. Firefox should adjust volume internally, like all other browsers and all other applications do.
Assignee | ||
Comment 42•4 years ago
|
||
It's there to prevent a burst of audio loud audio in the following scenario:
- Play some audio at a particular volume
- Pause the audio stream
- Adjust the volume
- Start the audio stream again
The only way to do this properly when the stream has a high latency is to use mixer-side volume. We've asked PulseAudio for a mixer-side input gain unaffected by the slider (that would be another gain stage), but afaik this is still not available.
We've tried to change this to use our own volume (which we already do if PulseAudio is configured to use flat-volumes, side-stepping the issue completely), but we backed it out because of a bug that we couldn't reproduce, and other things of more importance have taken precedence since then.
As always, this is in theory easy to fix, the code is there, it's only code removal, the patch has already been written.
If someone wants to fix this, and can reproduce and understands the bug resulting in no audio for quite a few people (in fact volume set to zero I think? but since ~nobody knows or care about per-app volume it's essentially equivalent), please tell us, and we can get this fixed.
Comment 43•4 years ago
|
||
I don't want to go over old ground, but this all started with Firefox's lamentable decision to use the PulseAudio API directly, in complete contradiction to PulseAudio's creator's intention. Firefox and Skype are the only applications which do this.
There's no reason to ever pause the audio stream, you should just feed it silence. There's a JACK backend for Firefox audio, and it does not (last time I checked) have this issue because the design is completely different.
Assignee | ||
Comment 44•4 years ago
|
||
(In reply to Paul Davis from comment #43)
There's no reason to ever pause the audio stream
Not burning the battery of a Bluetooth device and allowing audio-competing policy schemes to work are two immediate reasons.
Please stay civil and source your affirmations. We've been talking more than a few times with the PulseAudio developers and not a single time it was mentioned that we weren't supposed to use the PulseAudio API directly. Case in point, just search on the web for software that do any kind of audio IO, and you'll see that lots of them will use Pulse's API directly.
In addition, downstream distros are enabling ALSA and Jack, and this works fine, and we review and take patches, and we've added ways to not use PulseAudio if one really wants that. And finally, this work admirably for the immense majority of the population. If you're not happy, we can talk and make changes, as always.
Comment 45•4 years ago
|
||
It's not the responsibility of a PulseAudio client to address power management on remote devices. PulseAudio can take care of it that by itself (e.g. by pausing the bluetooth stream when the incoming PA stream from the application is silent for more than some period of time).
How does pausing the stream allow for competing schemes? One of the main points of PulseAudio is that multiple applications can all share access to audio interface hardware, and the PulseAudio server continues to run regardless of whether or not your stream is paused.
Lennart and I built a mechanism into PulseAudio and JACK to allow them to inter-operate; that mechanism is completely unrelated to whether or not PA streams are paused or not.
Sourcing my affirmations ... hmm, I was a friend of Lennart at the time he was working on PulseAudio. He had a very clear goal of not adding a new API for applications to use to do audio I/O. He made this clear to me personally, and at the Linux Plumbers Conference (2009 I believe), and in some discussions on the Linux Audio Developers mailing list (when we questioned him on precisely this point).
This is precisely why PulseAudio implements a pseudo-device so that applications using the ALSA API will just keep working, regardless of whether or not the PulseAudio device or some hardware device is being used by the application. Unfortunately, as Lennart moved on from PulseAudio, subsequent developers on the project were less insistent that the API should not be used by applications. In the period 2005-2015 (roughly), the PulseAudio documentation was fairly clear on this point, whereas today the same documentation does make it appear as if it really is intended to be an API for applications. Nevertheless, it still remains the case that, to the best of my knowledge, Firefox and Skype are the only applications to have taken the path of actually using the PulseAudio API.
Comment 46•4 years ago
|
||
Re: applications ... ok, doing your suggested search does point to some other applications that opted to use PulseAudio directly, so I stand corrected on this. I was suprised to find that Clementine, the audio player I use 100% of the time, does this. However, most of these applications offer multiple API choices. For Clementine, for example, I use it with JACK exclusively, and in fact it offers an almost crazy list of options.
Comment 47•4 years ago
|
||
If we could identify what in the system was setting volumes on new streams, then perhaps we could detect that and revert the fix for bug 1632093 in situations where that initial volume setting is not happening.
Updated•4 years ago
|
Comment 49•4 years ago
|
||
(In reply to Paul from comment #42)
I arrived here because I had this problem, the volume was going to zero when I pressed right or left key in a youtube video. Using FF 91.0.2 on Mageia 8.
I just understood the problem and I may have been able to reproduce, at least one part of it: I think what happened is that I had muted the tab without noticing it, then when the video plays, the sound volume in pulse is zero. So I increased the volume to 100%. Now, each time I do a fast forward (right key), the sound drops back to zero. So I change it back in pulse (pavucontrol or KDE sound mixer in my case), but it will drop to zero every time I do any small action, pause, forward, rewind, etc.
Unmute the tab allowed FF to be at 100% sound volume again, and it stays there - of course the bug is still there: if I change FF volume to e.g. 50% and do a fast fwd, the sound will go again to 100%.
But the mute problem was the most annoying problem for me, it had happened randomly in the past and I did not figure out why until today, so I wanted to leave a trace here so that people check if the tab is muted or not.
Updated•4 years ago
|
Comment 52•4 years ago
•
|
||
Compare our attempt with what chrone does , the only difference I noticed is that chrome adjusts the volume if its value is in [0, 1) while we adjust the volume if it's not 1. Not sure if it matters, or we guarantee the volume value is in [0, 1).
Comment 53•4 years ago
|
||
There are two separate issues here.
One is that the volume is reset at specific times when it should not be. For example, visit a bandcamp or similar page with a playlist. Start playing the first item in the list. Using PulseAudio Volume Control, change the volume for the page's audio stream. Now use a button on the page to skip to the next item. The volume is reset.
You can do the same on YT: start a video, use pavolctl to reduce the voume, then skip to a new location in the video. The volume is reset.
If you're going to adjust the volume in a system external to Firefox, you need to make the interaction duplex (i.e. notice changes made externally, not just those originating from HTML5 elements).
The second deeper issue is that as explained above, Firefox should not be adjusting PulseAudio (or ALSA or Pipewire) gain controls at all. These exist for users, not applications. Firefox should have its own internal gain system, and using HTML5 controls should alter only this internal gain system.
Comment 54•4 years ago
|
||
Hi, maybe can help to better find out the source of the problem.
I beging experiencing this bug ONLY after i upgraded from debian buster to debian bullseye.
Pulseaudio change from:
12.2 -> 14.2
Regards, Alberto.
Comment 55•4 years ago
|
||
Im experiencing the same issue but with Debian(bullseye)+Kde and netflix, everytime you pause and the restart a movie the audio get reset to 100%
Comment 56•4 years ago
|
||
Honestly, the best approach would be having a setting in about:config "do not alter volume"
Comment 57•4 years ago
|
||
Same problem involves both Midori and Gnome Web (was Epiphany), WebKit engine browsers. And confirm that Chrome is not affected.
(Hope this can help further, because problem is quite annoying.)
Comment 58•4 years ago
|
||
Please look at:
https://github.com/mozilla/cubeb-pulse-rs/pull/53/files#diff-4e446a2e6b4bdb3c1be55ef9b44ec4a2b1c04c15865a0fde7680d342b065a36aL640
Debian buster pulseaudio 12.2 default to:
flat-volumes = yes
Debian bullseye pulseaudio 14.2 default to:
flat-volumes = no
I tried changing bullseye pulseaudio conf back to "flat-volumes = yes" and problems disappeared!
I think we need to change code to always:
"apply our own gain instead of changing the input volume on the sink. "
and not only when pulseaudio is configured to use flat-volumes.
Regards, Alberto.
Comment 59•4 years ago
|
||
(In reply to mello+github from comment #58)
Please look at:
https://github.com/mozilla/cubeb-pulse-rs/pull/53/files#diff-4e446a2e6b4bdb3c1be55ef9b44ec4a2b1c04c15865a0fde7680d342b065a36aL640Debian buster pulseaudio 12.2 default to:
flat-volumes = yesDebian bullseye pulseaudio 14.2 default to:
flat-volumes = noI tried changing bullseye pulseaudio conf back to "flat-volumes = yes" and problems disappeared!
I think we need to change code to always:
"apply our own gain instead of changing the input volume on the sink. "and not only when pulseaudio is configured to use flat-volumes.
Regards, Alberto.
Thanks! this is helpful!
Paul, do you have a cycle to check if this works?
Comment 60•4 years ago
|
||
edited /etc/pulse/daemon.conf to set flat-volumes to no. ran pulseaudio -k (which stops and restarts pulse). visited a youtube video, played with volume. Pulse playback volume is modified by HTML5 video volume control.
edited /etc/pulse/daemon.conf to set flat-volumes to yes ran pulseaudio -k (which stops and restarts pulse). visited a youtube video, played with volume. Pulse playback volume is modified by HTML5 video volume control.
I do not have ~/.pulse or ~/.config/pulse/*.config
in short: I can't see any difference arising from this setting, even though I agree that from its description it ought to work.
Comment 61•4 years ago
|
||
maybe you already have done it, but i had to restart firefox to have it fixed.
Comment 62•4 years ago
|
||
That does indeed fix it. Still agree with C.M. Chang: "apply our own gain instead of changing the input volume on the sink. "
Comment 63•4 years ago
|
||
I can confirm with Kubuntu 21.10 (Pulseaudio 15.0). I set the youtube tab volume to 100% and whenever I reload the tab (I can always reproduce with reloading the tab but not always with pausing the video) the sound goes back to 79% (minutes ago it was 83% for some reason, not it's 79%)
Changing (flat-volume = yes) made the problem worse. Now the sound of firefox is "connected" to my main sound. So every time I pause the video and play it again, firefox' sound goes back to 79% and the speaker's volume goes up to 79% too (so the sound will get really loud). Lowering the speaker's sound (with the buttons from the keyboard) also lower's Firefox' application sound. And when I pause and resume, both go up again to 79%.
P.S: I tried Microsoft edge and I couldn't reproduce there. But Firefox with 79% is way more louder (and better) than 100% with Edge.
Comment 64•4 years ago
|
||
I can confirm it's happening on current Debian testing (Bookworm) using Mozilla's Firefox build (96.0b6). PulseAudio is running on Pipewire.
Comment 65•4 years ago
|
||
Can also confirm that this is still an issue running Firefox 95.0.2 (64-bit) on Arch linux. Pulse audio itself is running Version 15.0
Comment 66•4 years ago
|
||
This is so annoying. It is the only app that does this. I have always been a Firefox user (since beta 0.7), but this is kinda a deal breaker. Please, fix.
Comment 67•4 years ago
|
||
I use openSUSE Tumbleweed with Mozilla Nightly. I'm currently using pipewire with wireplumber. The only way I can control Firefox is by setting media.volume_scale
to some value around 0.3
that way the volume only increases to ~70% each time something new is played.
Comment 68•4 years ago
|
||
So is the above fix going to be added to Firefox?
Comment 69•4 years ago
|
||
Simple workaround for my needs was to set media.volume_scale
to 1.7
in firefox's about:config page. This will assure that the volume will always stay at 100% whenever you reload the tab or scrub through a video/audio.
For me this behaviour is fine cause i want firefox to stay at 100% volume and i can change the master volume for the whole system via keyboard.
You can experiment with different values of media.volume_scale
to get one fixed volume that fits your needs.
Updated•4 years ago
|
Comment 70•4 years ago
|
||
The severity field for this bug is relatively low, S3. However, the bug has 11 votes.
:padenot, could you consider increasing the bug severity?
For more information, please visit auto_nag documentation.
Comment 71•4 years ago
|
||
This has been reported 4 years ago and it's still an issue. I suggest to just ignore it and build a new decent audio stack on Pipewire.
But sadly I think Chromium will be the first browser in the next years to have native Pipewire support while Firefox will still rely on old Pulseaudio, maybe with this bug still open. Which unfortunately is one on many reasons why Firefox is losing market share.
Comment 72•3 years ago
|
||
Is this ever gonna be fixed ?
OpenSUSE tumble weed watching a play list on you tube.
Every freaking time , a new vids starts the volume increases.
Why can't fire fox leave my system volume alone ?
Are the firefox people trying to get me deaf, or are they trying to kill my headset ?
Don't wanna be rude, but I totally don't get why fire fox is resetting and or changing the volume.
For those that don't know OpenSUSE tumble weed, its a rolling release, so I am on the latest firefox version.
How can this have a low severity ?
Comment 73•3 years ago
|
||
Hello fellow frustrated Firefox users, a permanent actual (not just setting volume_scale) workaround for this is creating a UserScript for this. For those who don't know what a UserScript is, it is just a script ran when the page loads by a UserScript extension, like ViolentMonkey. Here is the UserScript I made to permanently set YouTube's volume to 100%:
// ==UserScript==
// @name Fix PulseAudio Volume
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/watch?v=*
// @grant none
// @version 1.0
// @author -
// @description 4/29/2022, 6:22:50 PM
// ==/UserScript==
const VOLUME_CHANGE_HANDLER = () => document.querySelector(".video-stream").volume = 1.0;
window.addEventListener("load", () => {
let videoStream = document.querySelector(".video-stream");
videoStream.addEventListener("volumechange", VOLUME_CHANGE_HANDLER);
videoStream.addEventListener("play", VOLUME_CHANGE_HANDLER);
VOLUME_CHANGE_HANDLER();
});
Comment 74•3 years ago
|
||
I don't understand why it can't be fixed in the code proper. Is anything blocking it?
Comment 75•3 years ago
|
||
Unsure if this will help to anyone - but since I've been looking into the BZ while seeking solution for my problem, here it goes:
I've spotted similar problem on my Rawhide - after 'playing' for a while with the 'easyeffects' app it happend that with each played 'youtube' video volume dropped to 0 (I'm using pipewire and I'm really unsure how I've got to this mode). But it's been highly annoying that after each song I'd to manual set volume back to 100% in 'pavucontrol' app. I've found the above mentioned script - but since I knew it's been playing before normally I've been seeking for better solution.
Even full system reboot did not helped at all. I've checked all about:config 'media.*' settings - they were in its defaults.
I've also noticed while playing the 'volume control' within Youtube player was not working at all.
Then I've 'flipped' the volume mute icon on the individual firefox's tab On/Off - and all of sudden functionality got restored back to normal - no need to set volume after each song, volume level is preserved properly.
firefox-100.0.2-2.fc37
pipewire-0.3.51-2.fc37
Maybe this helps to some....
Comment 76•3 years ago
|
||
(In reply to Hugo van de Kuilen from comment #73)
Modifying your code to dynamically adjust the pulseaudio volume to be what the youtube player actually says it is.
// ==UserScript==
// @name Fix PulseAudio Volume
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/watch?v=*
// @grant none
// @version 1.0
// @author -
// @description 7/15/2022, 12:03:50 AM
// ==/UserScript==
const VOLUME_CHANGE_HANDLER = () => {
const wrongVolume = document.querySelector(".video-stream").volume
const trueVolume = document.querySelector("#ytd-player").player_.getVolume() / 100;
console.log('wrong volume', wrongVolume);
console.log('true volume', trueVolume);
document.querySelector(".video-stream").volume = trueVolume;
}
window.addEventListener("load", () => {
let videoStream = document.querySelector(".video-stream");
videoStream.addEventListener("volumechange", VOLUME_CHANGE_HANDLER);
videoStream.addEventListener("play", VOLUME_CHANGE_HANDLER);
VOLUME_CHANGE_HANDLER();
});
Comment 77•3 years ago
|
||
Hi there,
I don't pretend to help, but
For me it's not a bug, when i open Deezer for example, if i enable "Normalize audio niveler" option, yes The Firefox volume is automatically adjusted, but when i disable this option, the volume stays to 100%.
I use Kubuntu 22.04.1 LTS.
Si for me it's a feature for normalize audio level to a constant level.
Comment 78•3 years ago
|
||
Why had nothing happened to fix this mess in FIVE YEARS ?
I never had this issue until this week. ( Fedora 35 LCDE spin; ffx 102; pipewire-0.3.56 )
I use a little taskbar widget to adjust sound levels. Once I set it it is constant and applies to all videos. All has been good until yesterday when I needed to use Audacity to edit some sound files. This says it needs Jack and seems to auto start it. In this case it seems to start pipewire which seems to be some kind of jack substitute.
Once I do that the "mixer" widget does not work any more and I have the kind of volume issues described above.
To set output volume I have to fire up PAVC. This lets be set the volume for the video but it seems to close the device and open a new one on each video and resets it to 100%. Worse, if I skip to different part of the same video, it resets the volume ! Also I watch a video clip in Twitter which is get to loop: every loop restart it resets the volume.
This is damned annoying and UNWORKABLE.
If I reboot I get the mixer widget back working .... until I run Audacity or PAVC.
What is this mess and why does it not get fixed?
Comment 79•3 years ago
|
||
The fix has already been noted above, but seems to implicate an interaction between the Firefox audio gain management design and a bug in at least one version of pulseaudio.
With the correct version of PA, setting "flat-volume" to one of the two possible values ("no" and "yes") will solve the issue.
On my system, at some point, setting PA to use "flat-volume = no" made everything work as I expected (and it used to be)
Comment 80•3 years ago
|
||
Thanks Paul, could you explain what you did for 'setting "flat-volume" to one of the two possible values ' ?
I had found that kind of solution and aped the suggestion:
echo 'flat-volumes = no' >> ~/.config/pulse/daemon.conf
It made no difference at all. I have no idea if that is correct for Fedora , out of date , or anything else.
Comment 81•3 years ago
|
||
I think after switching from PulseAudio to Pipewire + Pulse plugin this bug doesn't occur to me anymore, or at least I didn't notice it so far. So it's potentially another option to avoid it.
Comment 82•3 years ago
|
||
Thanks for the tip. What is this "pulse plugin" you refer too. Could give a package name?
Comment 83•3 years ago
|
||
In Debian testing I got pulseaudio package removed and now I only have a bunch of pipewire packages.
The plugin one is pipewire-pulse (0.3.59).
Comment 84•3 years ago
|
||
Thanks, on Fedora that's called pipewire-pulseaudio. I already had that installed. :(
Comment 85•3 years ago
|
||
From here: https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/Migrate-PulseAudio
flat flat-volumes should be always off with Pipewire.
Pulse related config can be found in /usr/share/pipewire/pipewire-pulse.conf
Comment 86•3 years ago
|
||
OK, I just encountered this bug again with Youtube in particular. So scrap the above. Not sure under what conditions it occurs though.
Comment 87•3 years ago
|
||
If according to above it's not a bug in Firefox, should I open a pipewire-pulse bug?
Comment 88•3 years ago
|
||
Correct , this is NOT a bug in Firefox.
The problem is seen in PAVC. Each time the an audio track ends , the source is removed from PAVC. The next time the same instance of FFx starts a new audio stream, a new device appears in PAVC with a new ( default ) volume of 100%. This included if I skip back 15s in the same video in FFx.
I imagine that PAVC is just reflecting underlying changes in pipewire, so it may be a more an issue with the underlying way data is streamed than the way PAVC is handling it. Someone with more understanding will need to determine that.
I have installed pssystray which at least gives me a more accessible volume control than swapping to PAVC every 30s to adjust volumes. The previous "mixer" applet which did volume control is now totally without effect.
Comment 89•3 years ago
|
||
correction : pasystray
Comment 90•3 years ago
|
||
This bug has nothing directly to do with pipewire. It occurs with the "pure" PulseAudio implementation too.
Comment 91•3 years ago
|
||
As is evidenced by the fact that the bug was logged 5 years ago before pipewire existed.
Comment 92•3 years ago
|
||
You know im really sad this hasn't been touched upon, im having the same problems with Artix Linux, KDE Plazma and pipewire, but ive found that this
https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a
script works well for nuking youtube's loudness normalisation, snippets that have been posted here didn't work on new "rounded" layout. Really disappointed by mozillas actions here, hope somebody finds this useful.
Comment 93•3 years ago
|
||
Given that none of the workarounds suggested in this lengthy bug report appear to resolve the issue I've finally just quit using FF on YouTube. MS Edge for Linux does not suffer from this blight so I've adopted it for the sole purpose of watching YT. Firefox is still my daily driver since the Phoenix days and I'll continue to evangelize it overall as the best browser available. Among the very few long-persisting unresolved issues in FF this one alone causes me serious pain as a user and renders this browser unusable for this particular use-case (watching YT streams at a consistent volume).
If desired I'd love to provide any meaningful and useful diagnostics and debugging information to @padenot
Comment 94•3 years ago
|
||
(In reply to tekstr1der from comment #93)
Given that none of the workarounds suggested in this lengthy bug report appear to resolve the issue I've finally just quit using FF on YouTube. MS Edge for Linux does not suffer from this blight so I've adopted it for the sole purpose of watching YT. Firefox is still my daily driver since the Phoenix days and I'll continue to evangelize it overall as the best browser available. Among the very few long-persisting unresolved issues in FF this one alone causes me serious pain as a user and renders this browser unusable for this particular use-case (watching YT streams at a consistent volume).
If desired I'd love to provide any meaningful and useful diagnostics and debugging information to @padenot
I second this. I love FF but this is just unbearably frustrating to say the least. I just want to play a series of music videos while doing dishes without having to come back to my desktop because the volume changes with every video.. Because of this I also feel forced to use Chrome or Edge just for playing YT vids which is just stupid. Might as well make the switch permanently until this get fixed.
That said, If you guys are in need of diags and logs and what not, I would also be happy to provide some as well cause I'd rather stick to FF as my only browser.
Comment 95•3 years ago
|
||
After some messing with pavucontrol and I did manage to get this sorted. Not sure that I can say exactly how.
Something about setting which audio channel is "default" and then FFx and others use it and it seems consistent.
Currently using Fed36 , Ffx108.0.1 and pipewireplumber.
IIRC it is still a mess as far as getting it to use a headset mike as input. It keeps defaulting to using the audio stream , if one is playing. Clearly it is trying to be far clever that it really is about "thinking" it knows what I want/need to do and trying to double guess me instead of just leaving things the way I set them.
Comment 96•3 years ago
|
||
I've also found this bug to be highly annoying. YT volume in the tab is always set to 100% however if I open pulseaudio I can see the actual volume anywhere from 50-90%. I then have to drag it manually to 100% in pulse. This now requires me to keep the pulseaudio dialog open so I can set the volume for every single video that plays. A waste of time. This bug was opened 5 years ago, this is very silly that this is still a problem.
Some claim it can't be a FF bug however it's the only application that has this problem. Everything else including other browsers work just fine. Something FF is doing audiowise is causing this problem.
Maybe if more budget was focused on fixing problems with the browser itself FF wouldn't be floundering like it is bleeding off users. It's sad too since it's the only option that isn't chrome based these days.
If logs are needed they just need to be asked for. It happen for every video I play on FF.
System information.
FF 110.0 (64-bit)
Operating System: Fedora Linux 37
KDE Plasma Version: 5.27.1
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.1.13-200.fc37.x86_64 (64-bit)
Comment 97•3 years ago
|
||
"Something FF is doing audiowise is causing this problem."
I would say more like something FF is doing audiowise is TRIGGERING this problem." That does not mean FFx is responsible.
Off the top of my head I think FFx is doing something like spawning a new process each time and this is seen as a new program instance which the new pulseaudio widgets are resetting each time. Other browsers may have a single audio device which remains open as long as the browser session is running.
Is see several processes like this running under FFx and AFAIK this is some kind of sandboxing of each tab as a security measure.
/usr/lib64/firefox/firefox -contentproc -childID 9213 -isForBrowser
Like I said above, I got around this by fiddling with pavucontrol and setting default channel or some such, so that it opens the new audio device with my chosen 70% volume instead of 100% each time. I don't have an exact method since I'm just going from memory of a lot of messing about.
Comment 98•3 years ago
|
||
The part confusing me as a simple user, is that this is still happening with pipewire too.
openSUSE thumbleweed.
It does however not happen in QMMP (a music player) it only happens with FF.
Maybe I am gonna try opera, because I do get the feeling the FF devs don't care.
This is a Five year old bug.......
Comment 99•3 years ago
|
||
IIRC my problems started when I did a Fedora distro upgrade and got stuffed with pipewire. I wasted about a week trying to find out what was wrong and get usable audio back.
IMO that (pipewire) is where the actual bug is. It seems to be trying to be far more clever than it's able and thinks it "knows" what you want/need to do and tries to think for you.
If QMMP just opens one audio stream ( which it likely does ) then that could explain the difference. Whinging and "threatening" to use a different browser is unlikely to change the amount of time FFx crew spend on your naive assumptions about where the problem lies. I've suggested you look at pavucontrol . If you do not have that pkg installed , I suggest you install it and try.
I still have issues with pipewire but at least I have a working FFx.
Comment 100•3 years ago
|
||
I am not threatening anybody.
I am starting to loose hope this will be fixed.
I installed pavu control and that did not change a thing.
Comment 101•3 years ago
|
||
media.default_volume is set to 0.5
Still on you tube volume jumps to 100% everytime.
Comment 102•3 years ago
|
||
Just want to add, that the presented workaround works fine for me too:
Environment: Debian Bullseye / KDE / Firefox 102.8.0esr
- Change pulse audio setting in /etc/pulese/daemon.conf flat_volume = yes
- Stop pulse audio server as logged in user pulseaudio -k
- Stop and Start again firefox
Comment 103•3 years ago
|
||
My mouse scroll button over the taskbar widget adjusts a global Builtin Audio Analog Stereo. I find this as a readout only under Default Sink submenu on the context menu of the widget. It is showing 18%.
In pavucontrol Output Devices tab , Builtin Audio Analog Stereo is set to Line-out.
Under playback tab, I see firefox ( when streaming a video ) set at 97% and linked to Builtin Audio Analog Stereo.
If I start a new tab in Firefox and play a new video it gets a new entry in playback tab and is set to 100%.
Each new video streaming in Ffx gets a new entry set at 100%.
All these play at same volume due to 18% setting on the default sink.
That seems logical, stable and works for me as a user.
Comment 104•3 years ago
|
||
(In reply to Tobias from comment #102)
Just want to add, that the presented workaround works fine for me too:
Environment: Debian Bullseye / KDE / Firefox 102.8.0esr
- Change pulse audio setting in /etc/pulese/daemon.conf flat_volume = yes
- Stop pulse audio server as logged in user pulseaudio -k
- Stop and Start again firefox
Your workaround works for PulseAudio but not for PipeWire.
Because PipeWire does not support flat_volume.
So Firefox itself should solve this problem.
Comment 105•3 years ago
|
||
"So Firefox itself should solve this problem."
how do you expect Firefox to take control of they audio subsystem on your computer ?!
Comment 106•3 years ago
|
||
The problem is that Firefox chooses to use "the audio subsystem" to control volume rather than applying gain internally. Instead of scaling the samples in its output to the audio subsystem, like 99% of other applications with audio output, it outputs the raw sample stream (at least in terms of volume) and then uses the audio subsystem API to adjust volume. This is such a wacky idea, and it's the heart of the problem (or was, the last time I looked at it).
Updated•3 years ago
|
Updated•3 years ago
|
Reporter | ||
Comment 107•3 years ago
|
||
I am no longer using pulse audio because I swapped to jack after putting in this bug and Iβm currently using pipewire. Both of these other audio systems do not exhibit this bug. Sorry I canβt help with reproducing this issue and verifying if itβs fixed
Comment 108•2 years ago
|
||
I get this bug with pipewire. Even pausing and playing the video resets firefox's volume. Idk why so many people are saying it is not a firefox bug when other browsers like chromium do not have this issue. Its certainly firefox that is at fault here
Comment 109•2 years ago
|
||
Yes, I'm getting the same problem with Firefox using EndeavourOS and pipewire. Playing random Youtube music videos causes the application volume to keep changing. It's so annoying! Chromium plays the same videos without issue.
Comment 110•2 years ago
|
||
idk what changed, but audio is somehow persisting with latest nightly on manjaro kde. Using pipewire 1:0.3.70-0
Comment 111•2 years ago
|
||
(In reply to crazylegoguy from comment #107)
I am no longer using pulse audio because I swapped to jack after putting in this bug and Iβm currently using pipewire. Both of these other audio systems do not exhibit this bug. Sorry I canβt help with reproducing this issue and verifying if itβs fixed
I'm getting this issue with Firefox 112.0.1 from Flathub on Kubuntu in Plasma with Pipewire 0.3.65 (I also have the same problem with the Snap install, so its not a Flatpak issue).
As far as I can tell, the issue is that Firefox sets the volume level directly on the stream the the Linux audio API (PA or PW) and never reads the volume back - so if one uses one of the system tools to change the "application volume" (actually, the specific stream volume, but it gets confused really easily - more on that later), Firefox will ignore that and reset the volume to what it was originally set when reopening the stream. This happens during seeking and when starting a new video (which again - gets complicated, more on that later) but - at least for me - not when pausing and unpausing after a short break.
There are a few additional complications:
- YouTube and various other sophisticated players have a volume setting in the HTML player and will remember the volume the user has set in Firefox and will reset to it when doing things like reloading the player or switching to another video; while other players may not set the volume and will start at a 100%.
- Even if an HTML player remembers the volume, and Firefox will read the volume change initiated by system tools and advertise it to the player (using the
volumechange
event) - the player may ignore this event and reset the volume at some later date, surprising the user. - Some system tools - like Plasma's task manager - set an "application level" volume which gets really messy really quickly. Specifically for Plasma's task manager, what it appears to be doing is showing the user the level of the stream with the highest volume, and when the user changes to volume, it scales all the streams in the amount that was changed: so if, for example, the browser has two streams, one set at 100% and one set at 50%, Plasma will show 100% volume, then the user sets 50% volume and Plasma will set the streams to 50% and 25% respectively. If the louder stream then stops and restarts at 100%, Plasma will show the application back to 100% and when the user sets 50% volume - Plasma will set the streams to 50% and 12.5% volume. Lather rinse repeat and it quickly becomes a huge issue.
The last problem is probably too complicated to be solved by Mozilla alone and I'm probably going to take this up with Plasma developers, but for all the other issues, Mozilla can rather quickly improve the user experience and should:
Firefox should definitely read back the stream value back from the system(*) and expose the current volume through the HTMLMedidElement.volume
attribute and the volumechange
event. I have verified that Firefox 112 does not do that currently.
At the very least it will solve the problem of users getting their volume reset by seeking, and if the HTML player is implemented correctly, it will also solve the problem of changing streams in the same service.
I also think that Firefox should also honor the volume set by the user using the system tools and when creating a new stream it should set the initial volume to the highest volume of any existing streams and/or the last volume set by system tools, to prevent loud audio blasting out at a user at the most unexpected time.
*) I'm not familiar with the PA API and whether it has volume change callbacks - I'm pretty sure it does, but slow polling would also likely be good enough.
Comment 113•2 years ago
|
||
I finally switched over from pulseaudio to pipewire about a month ago.
Indeed I should have tested pipewire prior to my comment #93. At least I got to try Edge for a year to view YT vids and it was solid throughout.
This issue has never once occurred again since the switch to pipewire with YouTube on FF. Software volume stays exactly where I set it (100%) in all cases.
Comment 114•2 years ago
|
||
I still experience this issue with pipewire 0.3.65-3 (on Ubuntu lunar). Here is a video demonstrating the problem with a non-Youtube player (the straightforward problem, not the complicated Plasma multi-stream-single-knob issue)
Comment 115•2 years ago
|
||
Yeah, still happens here with Arch-based distros (e.g. Manjaro) and Pipewire 0.3.84.
Comment 116•2 years ago
|
||
I think I noticed one pattern. When opening individual Youtube videos volume level works fine, but when playing a Youtube playlist, volume gets messed up (like being reduced from 100% after it switches the track).
Comment 117•2 years ago
|
||
I glued together a couple of scripts I found online and created this Tampermonkey solution. It grabs the volume level from UI slider and applies it to the actual video. This will completely overcome the volume normalization.
It also makes the volume level exponential, so replace Math.pow(slider_volume / 100, 3);
with slider_volume / 100
if you don't want that.
// ==UserScript==
// @name Fuck YouTube Normalization
// @namespace http://tampermonkey.net/
// @version v0.Yo.Mama-poops
// @description I don't know this garbo lang
// @author adamnejm
// @match https://www.youtube.com/*
// @match https://youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function get_fake_volume(){
var slider = document.getElementsByClassName("ytp-volume-panel")[0];
if (slider) {
var slider_volume = Number(slider.getAttribute("aria-valuenow"));
return Math.pow(slider_volume / 100, 3);
} else {
return 0;
}
}
const {get, set} = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'volume');
Object.defineProperty(HTMLMediaElement.prototype, 'volume', {
get(){
return get_fake_volume();
},
set(originalVolume){
setTimeout(() => {
set.call(this, get_fake_volume());
}, 0);
}
});
})();
![]() |
||
Updated•1 year ago
|
![]() |
||
Updated•1 year ago
|
Comment 118•1 year ago
|
||
Is anything happening with this?
Or does someone have a surefire way of forcing firefox on a different audio sink where the volume doesn't reset to whatever obnoxiously high value it wants to be set at?
Comment 119•1 year ago
|
||
I have the volume automatically set to 95% whenever I play a new video on firefox. It resets automatically even if I change it through pavucontrol manually. The system volume is 100% but I would like to boost firefox volume persistently.
I'm on Mozilla Firefox 131.0
Comment 120•1 year ago
|
||
Is there any update on this bug? It's the one thing keeping me from using firefox as my daily driver.
Comment 121•1 year ago
|
||
I'm currently using a separate virtual sink as a workaround to this issue, might be useful to some people:
context.modules = [
{
name = libpipewire-module-loopback
args = {
audio.position = [ FL FR ]
node.description = "Media Loopback"
capture.props = {
node.name = "media-sink"
node.description = "Media Sink"
media.class = "Audio/Sink"
node.passive = true
}
playback.props = {
node.name = "media-source"
node.description = "Media Source"
node.passive = true
}
}
}
]
Save this as ~/.config/pipewire/pipewire.conf.d/20-media-sink.conf
and restart pipewire with systemctl --user restart pipewire pipewire-pulse wireplumber
. After that you should be able to Firefox to that sink with an app like PavuControl or KDE Sound Settings and control volume of the sink instead of the application itself.
Comment 122•1 year ago
|
||
(In reply to Name from comment #121)
I'm currently using a separate virtual sink as a workaround to this issue, might be useful to some people:
context.modules = [ { name = libpipewire-module-loopback args = { audio.position = [ FL FR ] node.description = "Media Loopback" capture.props = { node.name = "media-sink" node.description = "Media Sink" media.class = "Audio/Sink" node.passive = true } playback.props = { node.name = "media-source" node.description = "Media Source" node.passive = true } } } ]
Save this as
~/.config/pipewire/pipewire.conf.d/20-media-sink.conf
and restart pipewire withsystemctl --user restart pipewire pipewire-pulse wireplumber
. After that you should be able to Firefox to that sink with an app like PavuControl or KDE Sound Settings and control volume of the sink instead of the application itself.
This didn't work for me. Firefox's volume is still reset when changing to a new point a youtube video.
Comment 123•1 year ago
|
||
(In reply to Patrick Collins from comment #122)
(In reply to Name from comment #121)
I'm currently using a separate virtual sink as a workaround to this issue, might be useful to some people:
context.modules = [ { name = libpipewire-module-loopback args = { audio.position = [ FL FR ] node.description = "Media Loopback" capture.props = { node.name = "media-sink" node.description = "Media Sink" media.class = "Audio/Sink" node.passive = true } playback.props = { node.name = "media-source" node.description = "Media Source" node.passive = true } } } ]
Save this as
~/.config/pipewire/pipewire.conf.d/20-media-sink.conf
and restart pipewire withsystemctl --user restart pipewire pipewire-pulse wireplumber
. After that you should be able to Firefox to that sink with an app like PavuControl or KDE Sound Settings and control volume of the sink instead of the application itself.This didn't work for me. Firefox's volume is still reset when changing to a new point a youtube video.
If you have a pipewire-pulse.conf file you can add a rule make it auto switch to that sink, I managed to get it working that way; it's still only working around the issue, though.
I'll post more precisely what I did in a follow up in case it's helpful, I'm currently mobile, so don't have it in front of me. But maybe that's enough for you to go on.
Comment 124•1 year ago
|
||
(In reply to philipp.leite from comment #123)
(In reply to Patrick Collins from comment #122)
(In reply to Name from comment #121)
I'm currently using a separate virtual sink as a workaround to this issue, might be useful to some people:
context.modules = [ { name = libpipewire-module-loopback args = { audio.position = [ FL FR ] node.description = "Media Loopback" capture.props = { node.name = "media-sink" node.description = "Media Sink" media.class = "Audio/Sink" node.passive = true } playback.props = { node.name = "media-source" node.description = "Media Source" node.passive = true } } } ]
Save this as
~/.config/pipewire/pipewire.conf.d/20-media-sink.conf
and restart pipewire withsystemctl --user restart pipewire pipewire-pulse wireplumber
. After that you should be able to Firefox to that sink with an app like PavuControl or KDE Sound Settings and control volume of the sink instead of the application itself.This didn't work for me. Firefox's volume is still reset when changing to a new point a youtube video.
If you have a pipewire-pulse.conf file you can add a rule make it auto switch to that sink, I managed to get it working that way; it's still only working around the issue, though.
I'll post more precisely what I did in a follow up in case it's helpful, I'm currently mobile, so don't have it in front of me. But maybe that's enough for you to go on.
I'd appreciate if you posted exactly what you did. I'm still relatively new to linux. Thanks!
Comment 125•1 year ago
|
||
(In reply to Patrick Collins from comment #124)
(In reply to philipp.leite from comment #123)
(In reply to Patrick Collins from comment #122)
(In reply to Name from comment #121)
I'm currently using a separate virtual sink as a workaround to this issue, might be useful to some people:
context.modules = [ { name = libpipewire-module-loopback args = { audio.position = [ FL FR ] node.description = "Media Loopback" capture.props = { node.name = "media-sink" node.description = "Media Sink" media.class = "Audio/Sink" node.passive = true } playback.props = { node.name = "media-source" node.description = "Media Source" node.passive = true } } } ]
Save this as
~/.config/pipewire/pipewire.conf.d/20-media-sink.conf
and restart pipewire withsystemctl --user restart pipewire pipewire-pulse wireplumber
. After that you should be able to Firefox to that sink with an app like PavuControl or KDE Sound Settings and control volume of the sink instead of the application itself.This didn't work for me. Firefox's volume is still reset when changing to a new point a youtube video.
If you have a pipewire-pulse.conf file you can add a rule make it auto switch to that sink, I managed to get it working that way; it's still only working around the issue, though.
I'll post more precisely what I did in a follow up in case it's helpful, I'm currently mobile, so don't have it in front of me. But maybe that's enough for you to go on.
I'd appreciate if you posted exactly what you did. I'm still relatively new to linux. Thanks!
The systems I've tried this on including Arch Linux and NixOS, didn't require anything other than switching Firefox to this virtual sink ONCE, it would then stay there forever, even after reboots. You can do this in KDE and probably Gnome settings, but here's the exact procedure for pavucontrol-qt
:
0. Create the virtual sink following instructions from my original comment
- Open Firefox and play some audio, eg. from a YouTube video
- Open PavuControl and navigate to the Playback page
- On the right hand side you should see a dropdown listing your sinks, eg.
on Starship/Matisse HD Audio Controller Analog Stereo
- Click on the dropdown and select Media Sink
- Done, now all streams from Firefox will be using that Sink
- Make sure to control the volume of the Media Sink, instead of Firefox itself an it'll stay in-place. Firefox cannot modify volume of that sink. You can do that in the Outputs Devices tab, using your desktop environment UI or through CLI like so:
- through pactl:
pactl set-sink-volume media-sink 50%
- through wpctl:
wpctl set-volume $(wpctl status | rg "(\d+).+media-sink" -or '$1') 0.5
Note thatpactl
is provided bypipewire-pulse
, which provides backwards compatibility for Pipewire.
This script is even useful outside of this Firefox issue, I put all of my media-playing apps in addition to Firefox, such as video and music players, which allows me to control volume of my media system-wide, especially music without affecting other programs, which comes really useful when playing video games. Then I just keep all my apps at 100% volume.
As for needing auto-switch in pipewire-pulse.conf
, I have never encountered this, however I can offer one general troubleshooting step you guys can try, which in the past has solved multitude of issues related to Pipewire for me, including speakers being used by default when booting up my PC, auto-mute (disabling speakers when headphones are plugged in) being wonky, auto-switching (apps not being moved to headphones / speakers when changing default sink) not working:
rm -r ~/.local/state/wireplumber/
This will remove your config cache and restore some stuff to their default values, eg. volumes of applications, card profiles, etc. So you'll have to open up Pavucontrol / system settings and reconfigure what you want, but clearing the state cache has been a real life savior when dealing with audio issues on Linux in general.
Comment 126•1 year ago
|
||
You see, just switching didn't work for me, hence my impatience on this being fixed XD
So I'm using a Steam Deck which I understand is running Arch Linux (or close enough?), I can very easily be wrong. In any case the issue is something that's persisted over a couple resets/reimagings of the device.
What I've ultimately found works, is adding or changing a bit in my default pipewire-pulse.conf file (in my case located in the /usr/share/pipewire/ directory). Note that this segment/stanza (whatever the correct terminology is) is already in the file for me, so I just had to uncomment or modify some things:
matches = [
{
# all keys must match the value. ! negates. ~ starts regex.
application.name = "Firefox"
#client.name = "Firefox"
#application.process.binary = "teams"
#application.name = "~speech-dispatcher.*"
}
]
actions = {
update-props = {
#node.latency = 512/48000
target.object = "input.Firefox-Sink"
}
# Possible quirks:"
# force-s16-info forces sink and source info as S16 format
# remove-capture-dont-move removes the capture DONT_MOVE flag
# block-source-volume blocks updates to source volume
# block-sink-volume blocks updates to sink volume
#quirks = [ ]
}
So the important bits up there are the application.name = "Firefox
bit in the matches section, which should pick that up from any ol' Firefox audio stream, then the target.object = "input.Firefox-Sink"
line under update-props.
'Firefox-Sink' is what I've called my sink, of course, so you'd replace that with whatever your sink name is, per the example given by Name in the earlier comment describing setting up the sink itself.
Then restarting the pipewire service should load these changes in, and hopefully you're up and running again.
The only caveat is that despite the documentation or other commenters pointing to particular locations as to where all these files are or should be, I didn't necessarily find them in the same place, so you may need to double-check.
Comment 127•1 year ago
|
||
Ah, I should have also mentioned that the 'matches' bit is under pulse.rules in my file. Like I said it's already in there by default so I only needed to amend it.
Comment 128•9 months ago
|
||
+1 from me too. Really annoying.
Comment 130•8 months ago
|
||
After attempting to use virtual sinks on arch i decided to mess around more with media.volume_scale
. When you reach 10.0, I have noticed that the volume doesn't reset. From 1.0 to 9.0 it would scale from 48% to 98% volume, the moment i set it to 10.0 it started working correctly, i tested it with skipping videos on YouTube, opening multiple tabs and closing and opening Firefox.
Comment 131•7 months ago
|
||
I've trying to figure out why Firefox changing its Pipewire/KDE audio slider was so annoying and like seeing the trees in the forest it finally it dawned on me: For Firefox this link between web-player and KDE audio slider is only working one way!
What do I mean of course it works both ways?
- When you change Volume in a Firefox web-player (eg. youtube, mp3 file, vimeo) the real audible volume is adjusted and the KDE audio slider for Firefox is moved accordingly.
- When you change Volume in the KDE audio slider for Firefox the real audible volume is adjusted but the Firefox web-players volume slider IS NOT updated! At this point both sliders are out of sync!
Yes the volume is adjusted correctly both ways, but Firefox does not update the volume control position of any web-player (audio or video element) when volume is changed from outside of Firefox! Now you might say, ofc Firefox can't update the volume slider for the web-player as there might be Javascript involved. MAYBE Firefox is simply not triggering the onvolumechange
event when the Pipewire volume is changed externally and this is an easy fix, but otherwise I feel that this feature is a fundamentally broken design.
On a related note:
Does anybody else have the issue that they cannot reduce the minimal volume using a web-players volume controls in Firefox below a certain threshold (eg. 20-25% in KDE) before the volume is muted instead, while controlling the Volume within KDE allows to go lower without issues.
![]() |
||
Updated•7 months ago
|
Comment 132•7 months ago
|
||
(In reply to ST from comment #130)
After attempting to use virtual sinks on arch i decided to mess around more with
media.volume_scale
. When you reach 10.0, I have noticed that the volume doesn't reset. From 1.0 to 9.0 it would scale from 48% to 98% volume, the moment i set it to 10.0 it started working correctly, i tested it with skipping videos on YouTube, opening multiple tabs and closing and opening Firefox.
Where exactly do you set media.volume_scale
to 10.0?
Comment 133•7 months ago
|
||
(In reply to Patrick Collins from comment #132)
(In reply to ST from comment #130)
After attempting to use virtual sinks on arch i decided to mess around more with
media.volume_scale
. When you reach 10.0, I have noticed that the volume doesn't reset. From 1.0 to 9.0 it would scale from 48% to 98% volume, the moment i set it to 10.0 it started working correctly, i tested it with skipping videos on YouTube, opening multiple tabs and closing and opening Firefox.Where exactly do you set
media.volume_scale
to 10.0?
In about:config
in the browser.
Comment 134•6 months ago
|
||
(In reply to ST from comment #130)
After attempting to use virtual sinks on arch i decided to mess around more with
media.volume_scale
. When you reach 10.0, I have noticed that the volume doesn't reset. From 1.0 to 9.0 it would scale from 48% to 98% volume, the moment i set it to 10.0 it started working correctly, i tested it with skipping videos on YouTube, opening multiple tabs and closing and opening Firefox.
Thanks. I have achieved the same with media.volume_scale
= 2.9
.
The default volume level was at 70% for me, trying to increase it 2.9 seems to correspond to about 99 - 100% volume.
Comment 135•6 months ago
|
||
(In reply to amithm7 from comment #134)
Thanks. I have achieved the same with
media.volume_scale
=2.9
.The default volume level was at 70% for me, trying to increase it 2.9 seems to correspond to about 99 - 100% volume.
Caveat: If I reduce video volume to 0 and increase (within the webpage), this issue pops up again. Volume starts at 56% and stays there.
Comment 136•5 months ago
|
||
(In reply to amithm7 from comment #134)
(In reply to ST from comment #130)
After attempting to use virtual sinks on arch i decided to mess around more with
media.volume_scale
. When you reach 10.0, I have noticed that the volume doesn't reset. From 1.0 to 9.0 it would scale from 48% to 98% volume, the moment i set it to 10.0 it started working correctly, i tested it with skipping videos on YouTube, opening multiple tabs and closing and opening Firefox.Thanks. I have achieved the same with
media.volume_scale
=2.9
.The default volume level was at 70% for me, trying to increase it 2.9 seems to correspond to about 99 - 100% volume.
I wanted to add my confirmation of this solution following the realization below:
(In reply to thomas.hufschmidt from comment #131)
I've trying to figure out why Firefox changing its Pipewire/KDE audio slider was so annoying and like seeing the trees in the forest it finally it dawned on me: For Firefox this link between web-player and KDE audio slider is only working one way!
What do I mean of course it works both ways?
- When you change Volume in a Firefox web-player (eg. youtube, mp3 file, vimeo) the real audible volume is adjusted and the KDE audio slider for Firefox is moved accordingly.
- When you change Volume in the KDE audio slider for Firefox the real audible volume is adjusted but the Firefox web-players volume slider IS NOT updated! At this point both sliders are out of sync!
Yes the volume is adjusted correctly both ways, but Firefox does not update the volume control position of any web-player (audio or video element) when volume is changed from outside of Firefox! Now you might say, ofc Firefox can't update the volume slider for the web-player as there might be Javascript involved. MAYBE Firefox is simply not triggering the
onvolumechange
event when the Pipewire volume is changed externally and this is an easy fix, but otherwise I feel that this feature is a fundamentally broken design.
I'm currently running Linux Mint and have had some problems with audio drivers (Mint packages with PipeWire now) since I was trying to figure out how to make my headphones and speakers more compatible (i.e., auto-switching between the two) on my desktop. Long story short, during that time, I discovered that YouTube (and by proxy Firefox) were consistently not at 100%, no matter how much and where I changed their volume.
I eventually found out that 100% in YouTube's volume slider corresponded (for me) with 79% in pavucontrol - I number I have seen referenced in other forum boards on this issue. This solution worked well for me (so far), and I found that media.volume_scale
= 2.5
now puts Firefox, with YouTube specifically, at 100%. From fiddling around with this scale value, I think it's probably on some exponential scaling factor since it's probably analyzing decibels - I mean, as in how much gain/signal strength Firefox is trying to assert to the audio driver - and is not caring about the front-facing percentage we see (hence the discrepancy). I could be wrong, but that was the feeling I got messing around with some of the values as it took less and less scaling to gain more and more "percentage"/decibels from Firefox to the audio driver.
If anyone has any better insight, solutions, and more, I'd love to hear to see if this should be approached as a Firefox issue alone, or a hardware/OS issue. What I mentioned previously about seeing 79% seems to be an indication to an issue on Firefox's end so I just want to add to that consensus on information and go from there.
Comment 137•5 months ago
|
||
(In reply to Austin from comment #136)
(In reply to thomas.hufschmidt from comment #131)
The behavior mentioned by Thomas, that uni-directional sync issue, is inconsistent.
I have seen volume in taskbar change (firefox stream) when video volume changes, sometimes only.
In my opinion, firefox should not attempt to sync volumes at all.
This issue might also be specific to FireFox + pipewire. I remember not having any issues with pulseaudio.
At this point I have started using Brave browser. This is issue is still at P3 priority.
Comment 138•4 months ago
|
||
If anyone needs it, I've modified Name's script from comment #117 for YouTube Music, as that was also suffering from the same issue.
Please note I've removed the exponential volume, so add it back as it was in that comment if you want it. All I did was find the appropriate element for Music and substitute it in. Both work great for me using ViolentMonkey.
// ==UserScript==
// @name Fuck YouTube Normalization - Music Edition
// @namespace http://tampermonkey.net/
// @version v0.Yo.Mama-poops-a-lot
// @description I don't know this garbo lang either
// @author adamnejm
// @match https://music.youtube.com/*
// @match https://www.music.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function get_fake_volume(){
var slider = document.getElementsByClassName("slider-knob-inner")[0];
if (slider) {
var slider_volume = Number(slider.getAttribute("value"));
return slider_volume / 100;
} else {
return 0;
}
}
const {get, set} = Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'volume');
Object.defineProperty(HTMLMediaElement.prototype, 'volume', {
get(){
return get_fake_volume();
},
set(originalVolume){
setTimeout(() => {
set.call(this, get_fake_volume());
}, 0);
}
});
})();
Comment 139•2 months ago
|
||
(In reply to Sinkerine from comment #28)
Repro with Firefox 84.0 on Arch Linux. A mitigation that works for me is to tweak the
media.volume_scale
option inabout:config
.
This "fixed" my problem with firefox 137 on MX linux. Since i always hold firefox on around 10% of the volume i had to find magic number to make this happen. For me is 0.035 but it will probably depend on your setup
Description
•