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

Video Wake Lock: wrap optimisation for hidden muted videos around a Feature flag.

Bug: 1086776
Change-Id: I90070ae55c0f6b9ee790ac4df9af1722b75f2489
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2225746
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774864}
parent fd56fc19
......@@ -323,7 +323,8 @@ void SetRuntimeFeaturesFromChromiumFeatures() {
device::kWebAuthGetAssertionFeaturePolicy, kUseFeatureState},
{wf::EnableTransformInterop, blink::features::kTransformInterop,
kUseFeatureState},
{wf::EnableVideoWakeLockOptimisationHiddenMuted,
media::kWakeLockOptimisationHiddenMuted, kUseFeatureState},
};
for (const auto& mapping : blinkFeatureToBaseFeatureMapping) {
SetRuntimeFeatureFromChromiumFeature(
......
......@@ -464,6 +464,9 @@ const base::Feature kFailUrlProvisionFetcherForTesting{
const base::Feature kHardwareSecureDecryption{
"HardwareSecureDecryption", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kWakeLockOptimisationHiddenMuted{
"kWakeLockOptimisationHiddenMuted", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables encrypted AV1 support in EME requestMediaKeySystemAccess() query by
// Widevine key system if it is also supported by the underlying Widevine CDM.
// This feature does not affect the actual playback of encrypted AV1 if it's
......
......@@ -171,6 +171,7 @@ MEDIA_EXPORT extern const base::Feature kVaapiLowPowerEncoderGen9x;
MEDIA_EXPORT extern const base::Feature kVaapiVP8Encoder;
MEDIA_EXPORT extern const base::Feature kVaapiVP9Encoder;
MEDIA_EXPORT extern const base::Feature kVideoBlitColorAccuracy;
MEDIA_EXPORT extern const base::Feature kWakeLockOptimisationHiddenMuted;
MEDIA_EXPORT extern const base::Feature kWidevineAv1;
MEDIA_EXPORT extern const base::Feature kWidevineAv1ForceSupportForTesting;
......
......@@ -242,8 +242,9 @@ class WebRuntimeFeatures {
BLINK_PLATFORM_EXPORT static void EnableTrustTokensAlwaysAllowIssuance(bool);
BLINK_PLATFORM_EXPORT static void EnableInstalledApp(bool);
BLINK_PLATFORM_EXPORT static void EnableTransformInterop(bool);
BLINK_PLATFORM_EXPORT static void EnableVideoWakeLockOptimisationHiddenMuted(
bool);
private:
WebRuntimeFeatures();
......
......@@ -30,7 +30,10 @@ VideoWakeLock::VideoWakeLock(HTMLVideoElement& video)
this, true);
VideoElement().addEventListener(event_type_names::kVolumechange, this, true);
StartIntersectionObserver();
if (RuntimeEnabledFeatures::VideoWakeLockOptimisationHiddenMutedEnabled())
StartIntersectionObserver();
else
is_visible_ = true;
RemotePlaybackController* remote_playback_controller =
RemotePlaybackController::From(VideoElement());
......@@ -43,8 +46,10 @@ VideoWakeLock::VideoWakeLock(HTMLVideoElement& video)
void VideoWakeLock::ElementDidMoveToNewDocument() {
SetExecutionContext(VideoElement().GetExecutionContext());
intersection_observer_->disconnect();
StartIntersectionObserver();
if (RuntimeEnabledFeatures::VideoWakeLockOptimisationHiddenMutedEnabled()) {
intersection_observer_->disconnect();
StartIntersectionObserver();
}
}
void VideoWakeLock::PageVisibilityChanged() {
......@@ -53,6 +58,8 @@ void VideoWakeLock::PageVisibilityChanged() {
void VideoWakeLock::OnVisibilityChanged(
const HeapVector<Member<IntersectionObserverEntry>>& entries) {
DCHECK(RuntimeEnabledFeatures::VideoWakeLockOptimisationHiddenMutedEnabled());
is_visible_ = (entries.back()->intersectionRatio() > 0);
Update();
}
......
......@@ -688,4 +688,10 @@ void WebRuntimeFeatures::EnableTransformInterop(bool enable) {
RuntimeEnabledFeatures::SetTransformInteropEnabled(enable);
}
void WebRuntimeFeatures::EnableVideoWakeLockOptimisationHiddenMuted(
bool enable) {
RuntimeEnabledFeatures::SetVideoWakeLockOptimisationHiddenMutedEnabled(
enable);
}
} // namespace blink
......@@ -1860,6 +1860,10 @@
{
name: "VideoRotateToFullscreen",
},
{
name: "VideoWakeLockOptimisationHiddenMuted",
status: "stable",
},
{
name: "VirtualKeyboard",
status: "test",
......
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