Bug 1845666 - Lock the media.utility-* prefs r=alwu

Differential Revision: https://phabricator.services.mozilla.com/D184734
This commit is contained in:
Alexandre Lissy 2023-08-31 10:56:55 +00:00
parent 7037097ca5
commit ded1182e37
7 changed files with 95 additions and 0 deletions

View File

@ -126,6 +126,33 @@ void MediaDecoder::InitStatics() {
MOZ_ASSERT(NS_IsMainThread());
// Eagerly init gMediaDecoderLog to work around bug 1415441.
MOZ_LOG(gMediaDecoderLog, LogLevel::Info, ("MediaDecoder::InitStatics"));
#if defined(NIGHTLY_BUILD)
// Allow people to force a bit but try to warn them about filing bugs if audio
// decoding does not work on utility
static const bool allowLockPrefs =
PR_GetEnv("MOZ_DONT_LOCK_UTILITY_PLZ_FILE_A_BUG") == nullptr;
if (XRE_IsParentProcess() && allowLockPrefs) {
// Lock Utility process preferences so that people cannot opt-out of
// Utility process
Preferences::Lock("media.utility-process.enabled");
# if defined(MOZ_FFMPEG)
Preferences::Lock("media.utility-ffmpeg.enabled");
# endif // defined(MOZ_FFMPEG)
# if defined(MOZ_FFVPX)
Preferences::Lock("media.utility-ffvpx.enabled");
# endif // defined(MOZ_FFVPX)
# if defined(MOZ_WMF)
Preferences::Lock("media.utility-wmf.enabled");
# endif // defined(MOZ_WMF)
# if defined(MOZ_APPLEMEDIA)
Preferences::Lock("media.utility-applemedia.enabled");
# endif // defined(MOZ_APPLEMEDIA)
Preferences::Lock("media.utility-vorbis.enabled");
Preferences::Lock("media.utility-wav.enabled");
Preferences::Lock("media.utility-opus.enabled");
}
#endif // defined(NIGHTLY_BUILD)
}
NS_IMPL_ISUPPORTS(MediaMemoryTracker, nsIMemoryReporter)

View File

@ -1,5 +1,9 @@
[DEFAULT]
support-files = head.js
# Set this since we want to continue monitoring the disabling of pref since we
# still allow it a little bit.
environment =
MOZ_DONT_LOCK_UTILITY_PLZ_FILE_A_BUG=1
[browser_audio_telemetry_content.js]
skip-if =

View File

@ -4,6 +4,10 @@ support-files =
head-multiple.js
prefs =
media.allow-audio-non-utility=true
# Set this since we want to continue monitoring the disabling of pref since we
# still allow it a little bit.
environment =
MOZ_DONT_LOCK_UTILITY_PLZ_FILE_A_BUG=1
[browser_utility_multipleAudio_fallback.js]
support-files =

View File

@ -0,0 +1,3 @@
[DEFAULT]
[browser_utility_audio_locked.js]

View File

@ -0,0 +1,24 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from head-multiple.js */
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/ipc/glue/test/browser/head-multiple.js",
this
);
add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["media.utility-process.enabled", false]],
});
});
add_task(async function testAudioDecodingInUtility() {
// TODO: When getting rid of audio decoding on non utility at all, this
// should be removed
const verifyForUtility = !!isNightly();
await runTest({ expectUtility: verifyForUtility });
});

View File

@ -8,6 +8,7 @@ BROWSER_CHROME_MANIFESTS += [
"browser.ini",
"browser_audio_fallback.ini",
"browser_audio_fallback_content.ini",
"browser_audio_locked.ini",
"browser_audio_shutdown.ini",
"browser_child_hang.ini",
]

View File

@ -526,6 +526,38 @@ const SNAPSHOT_SCHEMA = {
required: false,
type: "boolean",
},
"media.utility-process.enabled": {
required: false,
type: "boolean",
},
"media.utility-ffmpeg.enabled": {
required: false,
type: "boolean",
},
"media.utility-ffvpx.enabled": {
required: false,
type: "boolean",
},
"media.utility-wmf.enabled": {
required: false,
type: "boolean",
},
"media.utility-applemedia.enabled": {
required: false,
type: "boolean",
},
"media.utility-vorbis.enabled": {
required: false,
type: "boolean",
},
"media.utility-wav.enabled": {
required: false,
type: "boolean",
},
"media.utility-opus.enabled": {
required: false,
type: "boolean",
},
},
},
places: {