Commit 6db10514 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Add a microtask version of the video.rAF for testing.

We're noticing that running the video.rAF as part of the rendering steps
isn't always performant since the BeginFrame powering window.rAF is run
much later than the one powering video rendering - resulting in frequent
misses.

While trying to diagnose this issue and whether we should switch to
using a microtask we're running into issues where dev builds are not as
performant as official builds, so to ease testing and analysis land a
temporary microtask version of video.rAF behind a flag so we can compare
using Mac/Win canary builds more effectively.

Bug: 1012063
Change-Id: Ie0609717d1863800550e858efbe144c8c0dde624
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076180
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745602}
parent a10c3b6f
......@@ -384,6 +384,12 @@ const base::Feature kUseNewMediaCache{"use-new-media-cache",
const base::Feature kUseMediaHistoryStore{"UseMediaHistoryStore",
base::FEATURE_DISABLED_BY_DEFAULT};
// Causes video.requestAniationFrame to use a microtask instead of running with
// the rendering steps. TODO(crbug.com/1012063): Remove this once we figure out
// which implementation to use.
const base::Feature kUseMicrotaskForVideoRAF{"UseMicrotaskForVideoRAF",
base::FEATURE_DISABLED_BY_DEFAULT};
// Use R16 texture for 9-16 bit channel instead of half-float conversion by CPU.
const base::Feature kUseR16Texture{"use-r16-texture",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -158,6 +158,7 @@ MEDIA_EXPORT extern const base::Feature kUnifiedAutoplay;
MEDIA_EXPORT extern const base::Feature kUseAndroidOverlayAggressively;
MEDIA_EXPORT extern const base::Feature kUseFakeDeviceForMediaStream;
MEDIA_EXPORT extern const base::Feature kUseMediaHistoryStore;
MEDIA_EXPORT extern const base::Feature kUseMicrotaskForVideoRAF;
MEDIA_EXPORT extern const base::Feature kUseNewMediaCache;
MEDIA_EXPORT extern const base::Feature kUseR16Texture;
MEDIA_EXPORT extern const base::Feature kVaapiH264AMDEncoder;
......
include_rules = [
"+media/base/media_switches.h",
"+media/base/video_frame.h",
]
\ No newline at end of file
]
......@@ -7,12 +7,14 @@
#include <memory>
#include <utility>
#include "media/base/media_switches.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_video_frame_metadata.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/scripted_animation_controller.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/modules/video_raf/video_frame_request_callback_collection.h"
#include "third_party/blink/renderer/platform/bindings/microtask.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
......@@ -69,12 +71,24 @@ void VideoRequestAnimationFrameImpl::OnRequestAnimationFrame() {
if (!pending_execution_) {
pending_execution_ = true;
GetSupplementable()
->GetDocument()
.GetScriptedAnimationController()
.ScheduleVideoRafExecution(
WTF::Bind(&VideoRequestAnimationFrameImpl::ExecuteFrameCallbacks,
WrapWeakPersistent(this)));
if (base::FeatureList::IsEnabled(media::kUseMicrotaskForVideoRAF)) {
auto& time_converter =
GetSupplementable()->GetDocument().Loader()->GetTiming();
Microtask::EnqueueMicrotask(WTF::Bind(
&VideoRequestAnimationFrameImpl::ExecuteFrameCallbacks,
WrapWeakPersistent(this),
// TODO(crbug.com/1012063): Now is probably not the right value.
time_converter
.MonotonicTimeToZeroBasedDocumentTime(base::TimeTicks::Now())
.InMillisecondsF()));
} else {
GetSupplementable()
->GetDocument()
.GetScriptedAnimationController()
.ScheduleVideoRafExecution(
WTF::Bind(&VideoRequestAnimationFrameImpl::ExecuteFrameCallbacks,
WrapWeakPersistent(this)));
}
}
}
......
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