Closed Bug 1153823 Opened 9 years ago Closed 9 years ago

Property "media.getusermedia.agc_enabled" (in about:config) is ignored.

Categories

(Core :: WebRTC: Audio/Video, defect)

37 Branch
x86_64
Windows 8.1
defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: mat.leoon, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36

Steps to reproduce:

Property "media.getusermedia.agc_enabled" (in about:config) is set to "false" by default, but Firefox is adjusting mic level anyway.


Actual results:

In Windows, in microphone device properties I can see that Microphone level is being changed when I speak to microphone while using a web application that requires it. 


Expected results:

Nothing should happen. Microphone level should remain unchanged. 

I have no other application that could change this.

Application run on Chrome doesn't do that, so it's a Firefox issue
Severity: normal → major
Component: Untriaged → WebRTC: Audio/Video
Product: Firefox → Core
Juan -- Can you repro this?  If so, can you confirm it for triage.
Flags: needinfo?(jbecerra)
I am able to reproduce this problem on the latest Firefox Dev Edition (41.0a2) and Nightly (42.0a1). Toggling the pref media.getusermedia.agc_enabled does nothing. When I look at the microphone properties in the Sound control panel I see that the microphone level adjusts when you speak to mic.

Chrome doesn't seem to do this.

I tried this on Windows 8.1
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jbecerra)
Priority: -- → P2
The correct way to confirm this bug is to check if the log message from MediaEngineWebRTCAudioSource::Config() says AGC is on.  (mediamanager:5 logging should show it.)  Note that AGC on/off may *not* affect what Windows does with the level, just whether internal AGC is on or off.  We default to off, but Windows may well default to On.

Also: what level did you look at?  The "Recording" tab of Sound will show the current level heard by the mic - but that's not the recording level, which is in Properties for a given mic in Levels.  I don't see those move while talking - and I don't really expect them to; the AGC that the pref turns on and off is inside webrtc, not controlling the OS boost levels (AGC has to react *fast*).

To check the operation of webrtc's AGC if we don't trust the log message we should use a reference tone at different levels recorded in WebRTC and in (say) Audacity, and see if the levels are "compressed" in WebRTC.  I.e. AGC will make moderately to soft things louder, and loud things less loud.  Really quiet things should stay quiet (to avoid pumping noise up too much).  However, I'd trust the log message to start with barring evidence to the contrary.

Back to Unconfirmed for another pass
Status: NEW → UNCONFIRMED
Ever confirmed: false
Flags: needinfo?(jbecerra)
Priority: P2 → --
I added the system environment variables and specified the log file on my Windows system, and when I attempt to make a Hello call to check this report I get a consistent crash like: https://crash-stats.mozilla.com/report/index/a19e8034-a221-462b-a4b0-1cf8a2150728

Before the browser crashes, the nspr log shows:

0[1311140]: mozilla::MediaManager::MediaManager: default prefs: 0x0 @30fps (min 10)
0[1311140]: New Media thread for gum
0[188f1c50]: mozilla::MediaEngineWebRTCVideoSource::Init
0[188f1c50]: Selected video device
0[188f1c50]: Selected audio device
0[188f1c50]: Audio device -1 allocated
0[188f1c50]: mozilla::MediaEngineWebRTCVideoSource::Allocate
0[188f1c50]: ChooseCapability: prefs: 640x480 @30-10fps
0[188f1c50]: Constraints: width: { min: -2147483647, max: 2147483647 }
0[188f1c50]:              height: { min: -2147483647, max: 2147483647 }
0[188f1c50]:              frameRate: { min: -1.#INF00, max: 1.#INF00 }
0[188f1c50]: chose cap 640x480 @30fps codec 7 raw 2
0[188f1c50]: Video device 4097 allocated
0[188f1c50]: Audio config: aec: -1, agc: -1, noise: 1
0[188f1c50]: Start audio for stream e226880
0[188f1c50]: Audio config: aec: -1, agc: -1, noise: 0
0[188f1c50]: mozilla::MediaEngineWebRTCVideoSource::Start
0[188f1c50]: started all sources
0[188ee7d0]: NotifyPull, desired = 384
0[12bfa0c0]: Video FrameSizeChange: 640x480

Does "agc:-1" mean it's off? I had the preference set to false during this test.

As far as the level I was looking at, I went to the Sound control panel, Recording tab, picked the headset microphone, then Properties, then Levels tab.
Flags: needinfo?(jbecerra)
(In reply to juan becerra [:juanb] from comment #4)
> I added the system environment variables and specified the log file on my
> Windows system, and when I attempt to make a Hello call to check this report
> I get a consistent crash like:
> https://crash-stats.mozilla.com/report/index/a19e8034-a221-462b-a4b0-
> 1cf8a2150728

You must be on Windows; there's a bad LOG statement due to Win32 & MSVC's handling of %lu.  mediamanager:4 likely would be ok.  However, in any case it got the info we needed.

> 0[188f1c50]: Audio config: aec: -1, agc: -1, noise: 1
> 0[188f1c50]: Start audio for stream e226880
> 0[188f1c50]: Audio config: aec: -1, agc: -1, noise: 0

> Does "agc:-1" mean it's off? I had the preference set to false during this
> test.

Yes.  That means aAgcOn is false, so we *won't* call SetAgcStatus.  Agc (unlike NS or AEC) defaults to on (either analog (on desktop), or digital (mobile); basically we can control the type of Agc.  This does point out that there's no way to set no-agc; enabled 0 is "unchanged", enabled 1 is "default", and not enabled will leave it on at default.  In fact in the webrtc.org code, there *is* no api for turning off Agc; you'd have to call into it directly.

> 
> As far as the level I was looking at, I went to the Sound control panel,
> Recording tab, picked the headset microphone, then Properties, then Levels
> tab.

Is there one control there or two?  What's shown there depends on the HW; my USB headset shows a single Microphone slider (at 100, the top, always).  My built-in mic has *two* sliders, one Microphone (100), and one Boost (+30db at the moment).

My headset mic *does* have the microphone slider move down (never up) if I talk loudly into it, and so does the internal mic.  However, this appears to be OS clipping-avoidance and persists even after audio devices are closed; this is not the AGC setting inside Firefox/WebRTC.  I'll note that (as reported) if I open the mic in Chrome and talk loudly into it, the volume does NOT go down.  Since Chrome *always* uses AGC, clearly the Level changes observed are NOT the internal AGC.  Likely they're opening the audio device in a different manner that locks the OS volume (perhaps in a different mode where the application is responsible for controlling levels/AGC?)

Also note that AGC is for *raising* levels when they're too soft (to be more precise, doing dynamic compression of the audio), not lowering too-loud ones.

So to test if this setting is ignored or not (the bug report), you need to check the log message with agc enabled in about:config (and the value set above 1); we've confirmed it does correctly know that Agc is "not enabled" (actually maps to enabled with default settings)
Hi Juan -- Randell meant to do a needinfo to you on this.  See comment 5 for his questions.  I'd like to confirm this by EOD Tuesday, if possible.
Flags: needinfo?(jbecerra)
Rithesh -- Can I ask you to pick this up since Juan has left?  I'm just looking to confirm if this bug is reproducible or not.  Juan thought he could repro, but Randell can't repro. 

I realize this week (coming up) is your last, but I believe this should not take more than an hour to confirm.  If I'm mistaken or if you really don't have the time, please let me know.  Thanks.
Flags: needinfo?(jbecerra) → needinfo?(r.shenthar)
Flags: needinfo?(r.shenthar) → needinfo?(rshenthar)
The setting is definitely reflected in the logs (as per checking the bug the *correct* way) ->

> So to test if this setting is ignored or not (the bug report), you need to
> check the log message with agc enabled in about:config (and the value set
> above 1); we've confirmed it does correctly know that Agc is "not enabled"
> (actually maps to enabled with default settings)

NSPR logs with media.getusermedia.agc_enabled set to true:
0[123b6d10]: Audio config: aec: 1, agc: 1, noise: 1



NSPR logs with media.getusermedia.agc_enabled set to false:
0[123b6d10]: Audio config: aec: 1, agc: -1, noise: 1
Flags: needinfo?(rshenthar) → needinfo?
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Flags: needinfo?
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.