Commit a7f95fad authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Autoplay: add Feature/Runtime flags to turn on/off restrictions on Web Audio.

This is adding a flag to be able to control whether Web Audio should be
restricted by autoplay. It will allow testing and experimenting.

Bug: 841933
Change-Id: Icdec2e74b210f0cf49db87f79ac9a1cb60d94d63
Reviewed-on: https://chromium-review.googlesource.com/1067148Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560350}
parent a19d7e5d
...@@ -452,6 +452,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs( ...@@ -452,6 +452,9 @@ void SetRuntimeFeaturesDefaultsAndUpdateFromArgs(
WebRuntimeFeatures::EnableOriginTrialControlledFeatures(false); WebRuntimeFeatures::EnableOriginTrialControlledFeatures(false);
} }
WebRuntimeFeatures::EnableAutoplayIgnoresWebAudio(
base::FeatureList::IsEnabled(media::kAutoplayIgnoreWebAudio));
// Enable explicitly enabled features, and then disable explicitly disabled // Enable explicitly enabled features, and then disable explicitly disabled
// ones. // ones.
for (const std::string& feature : for (const std::string& feature :
......
...@@ -320,6 +320,12 @@ const base::Feature kLowDelayVideoRenderingOnLiveStream{ ...@@ -320,6 +320,12 @@ const base::Feature kLowDelayVideoRenderingOnLiveStream{
"low-delay-video-rendering-on-live-stream", "low-delay-video-rendering-on-live-stream",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
// Whether the autoplay policy should ignore Web Audio. When ignored, the
// autoplay policy will be hardcoded to be the legacy one on based on the
// platform
const base::Feature kAutoplayIgnoreWebAudio{"AutoplayIgnoreWebAudio",
base::FEATURE_ENABLED_BY_DEFAULT};
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Lock the screen orientation when a video goes fullscreen. // Lock the screen orientation when a video goes fullscreen.
const base::Feature kVideoFullscreenOrientationLock{ const base::Feature kVideoFullscreenOrientationLock{
......
...@@ -104,6 +104,7 @@ namespace media { ...@@ -104,6 +104,7 @@ namespace media {
// All features in alphabetical order. The features should be documented // All features in alphabetical order. The features should be documented
// alongside the definition of their values in the .cc file. // alongside the definition of their values in the .cc file.
MEDIA_EXPORT extern const base::Feature kAutoplayIgnoreWebAudio;
MEDIA_EXPORT extern const base::Feature kAv1Decoder; MEDIA_EXPORT extern const base::Feature kAv1Decoder;
MEDIA_EXPORT extern const base::Feature kBackgroundVideoPauseOptimization; MEDIA_EXPORT extern const base::Feature kBackgroundVideoPauseOptimization;
MEDIA_EXPORT extern const base::Feature kBackgroundVideoTrackOptimization; MEDIA_EXPORT extern const base::Feature kBackgroundVideoTrackOptimization;
......
...@@ -191,6 +191,7 @@ class WebRuntimeFeatures { ...@@ -191,6 +191,7 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableOffMainThreadWebSocket(bool); BLINK_PLATFORM_EXPORT static void EnableOffMainThreadWebSocket(bool);
BLINK_PLATFORM_EXPORT static void EnableExperimentalProductivityFeatures( BLINK_PLATFORM_EXPORT static void EnableExperimentalProductivityFeatures(
bool); bool);
BLINK_PLATFORM_EXPORT static void EnableAutoplayIgnoresWebAudio(bool);
private: private:
WebRuntimeFeatures(); WebRuntimeFeatures();
......
...@@ -684,13 +684,19 @@ Document* BaseAudioContext::GetDocument() const { ...@@ -684,13 +684,19 @@ Document* BaseAudioContext::GetDocument() const {
} }
AutoplayPolicy::Type BaseAudioContext::GetAutoplayPolicy() const { AutoplayPolicy::Type BaseAudioContext::GetAutoplayPolicy() const {
// The policy is different on Android compared to Desktop. if (RuntimeEnabledFeatures::AutoplayIgnoresWebAudioEnabled()) {
// When ignored, the policy is different on Android compared to Desktop.
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
return AutoplayPolicy::Type::kUserGestureRequired; return AutoplayPolicy::Type::kUserGestureRequired;
#else #else
// Force no user gesture required on desktop. // Force no user gesture required on desktop.
return AutoplayPolicy::Type::kNoUserGestureRequired; return AutoplayPolicy::Type::kNoUserGestureRequired;
#endif #endif
}
Document* document = GetDocument();
DCHECK(document);
return AutoplayPolicy::GetAutoplayPolicyForDocument(*document);
} }
bool BaseAudioContext::AreAutoplayRequirementsFulfilled() const { bool BaseAudioContext::AreAutoplayRequirementsFulfilled() const {
......
...@@ -520,4 +520,8 @@ void WebRuntimeFeatures::EnableDisplayCutoutViewportFit(bool enable) { ...@@ -520,4 +520,8 @@ void WebRuntimeFeatures::EnableDisplayCutoutViewportFit(bool enable) {
RuntimeEnabledFeatures::SetDisplayCutoutViewportFitEnabled(enable); RuntimeEnabledFeatures::SetDisplayCutoutViewportFitEnabled(enable);
} }
void WebRuntimeFeatures::EnableAutoplayIgnoresWebAudio(bool enable) {
RuntimeEnabledFeatures::SetAutoplayIgnoresWebAudioEnabled(enable);
}
} // namespace blink } // namespace blink
...@@ -112,6 +112,10 @@ ...@@ -112,6 +112,10 @@
name: "AutomationControlled", name: "AutomationControlled",
settable_from_internals: true, settable_from_internals: true,
}, },
{
// Flag set by the media::kAutoplayIgnoreWebAudio feature flag.
name: "AutoplayIgnoresWebAudio",
},
{ {
name: "AutoplayMutedVideos", name: "AutoplayMutedVideos",
settable_from_internals: true, settable_from_internals: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment