Bug 1564466 - Make MediaSource not call Preferences::GetBool off-main-thread. r=jya

Preferences::GetBool is not thread-safe, StaticPrefs are.
Also StaticPrefs are nicer anyway.

There's a lot of Preferences:: usage in dom/media which looks suspicious, though
I don't know if all that runs on the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D38097

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-07-18 13:06:17 +00:00
parent 28af937c05
commit f34964f6bc
4 changed files with 41 additions and 26 deletions

View File

@ -18,7 +18,6 @@
#include "SourceBufferList.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/Preferences.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/HTMLMediaElement.h"
@ -110,13 +109,13 @@ nsresult MediaSource::IsTypeSupported(const nsAString& aType,
const MediaMIMEType& mimeType = containerType->Type();
if (mimeType == MEDIAMIMETYPE("video/mp4") ||
mimeType == MEDIAMIMETYPE("audio/mp4")) {
if (!Preferences::GetBool("media.mediasource.mp4.enabled", false)) {
if (!StaticPrefs::media_mediasource_mp4_enabled()) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
return NS_OK;
}
if (mimeType == MEDIAMIMETYPE("video/webm")) {
if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
if (!(StaticPrefs::media_mediasource_webm_enabled() ||
StaticPrefs::media_media_capabilities_enabled() ||
containerType->ExtendedType().Codecs().Contains(
NS_LITERAL_STRING("vp8")) ||
@ -131,8 +130,8 @@ nsresult MediaSource::IsTypeSupported(const nsAString& aType,
return NS_OK;
}
if (mimeType == MEDIAMIMETYPE("audio/webm")) {
if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
Preferences::GetBool("media.mediasource.webm.audio.enabled", true))) {
if (!(StaticPrefs::media_mediasource_webm_enabled() ||
StaticPrefs::media_mediasource_webm_audio_enabled())) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
return NS_OK;
@ -430,12 +429,14 @@ bool MediaSource::IsTypeSupported(const GlobalObject& aOwner,
/* static */
bool MediaSource::Enabled(JSContext* cx, JSObject* aGlobal) {
return Preferences::GetBool("media.mediasource.enabled");
// FIXME(emilio): Looks like this should just use [Pref="..."] on the IDL.
return StaticPrefs::media_mediasource_enabled();
}
/* static */
bool MediaSource::ExperimentalEnabled(JSContext* cx, JSObject* aGlobal) {
return Preferences::GetBool("media.mediasource.experimental.enabled");
// FIXME(emilio): Looks like this should just use [Pref="..."] on the IDL.
return StaticPrefs::media_mediasource_experimental_enabled();
}
void MediaSource::SetLiveSeekableRange(double aStart, double aEnd,

View File

@ -4466,6 +4466,39 @@
mirror: always
#undef PREF_VALUE
# MediaSource
# Whether to enable MediaSource support.
- name: media.mediasource.enabled
type: RelaxedAtomicBool
value: true
mirror: always
- name: media.mediasource.mp4.enabled
type: RelaxedAtomicBool
value: true
mirror: always
- name: media.mediasource.webm.enabled
type: RelaxedAtomicBool
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
value: true
#else
value: false
#endif
mirror: always
- name: media.mediasource.webm.audio.enabled
type: RelaxedAtomicBool
value: true
mirror: always
# Whether to enable MediaSource v2 support.
- name: media.mediasource.experimental.enabled
type: RelaxedAtomicBool
value: false
mirror: always
# VideoSink
- name: media.ruin-av-sync.enabled
type: RelaxedAtomicBool

View File

@ -411,21 +411,6 @@ pref("media.webvtt.pseudo.enabled", true);
// WebVTT debug logging.
pref("media.webvtt.debug.logging", false);
// Whether to enable MediaSource support.
pref("media.mediasource.enabled", true);
pref("media.mediasource.mp4.enabled", true);
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID)
pref("media.mediasource.webm.enabled", false);
#else
pref("media.mediasource.webm.enabled", true);
#endif
pref("media.mediasource.webm.audio.enabled", true);
// Whether to enable MediaSource v2 support.
pref("media.mediasource.experimental.enabled", false);
pref("media.benchmark.vp9.threshold", 150);
pref("media.benchmark.frames", 300);
pref("media.benchmark.timeout", 1000);

View File

@ -10,10 +10,6 @@
[decodingInfo.any.worker.html]
expected:
if release_or_beta and (os == "android") and not debug: OK
if not debug and (os == "android"): CRASH
if debug: CRASH
[Test that decodingInfo returns a valid MediaCapabilitiesInfo objects]
expected: FAIL