Commit d81a0e64 authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Create base::Feature for using video capture API in DevTools

Create a base::Feature for using video capture API in DevTools so we
can do finch trial independent of Viz.

Bug: 813929
Change-Id: I44da043f473d8be663931306e7e9dd296143b1c4
Reviewed-on: https://chromium-review.googlesource.com/963183Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Saman Sami <samans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543972}
parent 4fbb5c6f
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/cursor_info.h" #include "content/public/common/cursor_info.h"
#include "content/public/common/screen_info.h" #include "content/public/common/screen_info.h"
#include "media/base/limits.h" #include "media/base/limits.h"
...@@ -31,8 +32,10 @@ DevToolsEyeDropper::DevToolsEyeDropper(content::WebContents* web_contents, ...@@ -31,8 +32,10 @@ DevToolsEyeDropper::DevToolsEyeDropper(content::WebContents* web_contents,
last_cursor_y_(-1), last_cursor_y_(-1),
host_(nullptr), host_(nullptr),
video_consumer_binding_(this), video_consumer_binding_(this),
enable_viz_( use_video_capture_api_(
base::FeatureList::IsEnabled(features::kVizDisplayCompositor)), base::FeatureList::IsEnabled(features::kVizDisplayCompositor) ||
base::FeatureList::IsEnabled(
features::kUseVideoCaptureApiForDevToolsSnapshots)),
weak_factory_(this) { weak_factory_(this) {
mouse_event_callback_ = mouse_event_callback_ =
base::Bind(&DevToolsEyeDropper::HandleMouseEvent, base::Unretained(this)); base::Bind(&DevToolsEyeDropper::HandleMouseEvent, base::Unretained(this));
...@@ -51,8 +54,7 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) { ...@@ -51,8 +54,7 @@ void DevToolsEyeDropper::AttachToHost(content::RenderWidgetHost* host) {
host_ = host; host_ = host;
host_->AddMouseEventCallback(mouse_event_callback_); host_->AddMouseEventCallback(mouse_event_callback_);
// TODO(crbug.com/813929): Use video capturer even if viz is not enabled. if (!use_video_capture_api_)
if (!enable_viz_)
return; return;
// Capturing a full-page screenshot can be costly so we shouldn't do it too // Capturing a full-page screenshot can be costly so we shouldn't do it too
...@@ -118,7 +120,7 @@ void DevToolsEyeDropper::DidReceiveCompositorFrame() { ...@@ -118,7 +120,7 @@ void DevToolsEyeDropper::DidReceiveCompositorFrame() {
} }
void DevToolsEyeDropper::UpdateFrame() { void DevToolsEyeDropper::UpdateFrame() {
if (enable_viz_ || !host_ || !host_->GetView()) if (use_video_capture_api_ || !host_ || !host_->GetView())
return; return;
// TODO(miu): This is the wrong size. It's the size of the view on-screen, and // TODO(miu): This is the wrong size. It's the size of the view on-screen, and
...@@ -139,7 +141,7 @@ void DevToolsEyeDropper::ResetFrame() { ...@@ -139,7 +141,7 @@ void DevToolsEyeDropper::ResetFrame() {
} }
void DevToolsEyeDropper::FrameUpdated(const SkBitmap& bitmap) { void DevToolsEyeDropper::FrameUpdated(const SkBitmap& bitmap) {
DCHECK(!enable_viz_); DCHECK(!use_video_capture_api_);
if (bitmap.drawsNothing()) if (bitmap.drawsNothing())
return; return;
frame_ = bitmap; frame_ = bitmap;
......
...@@ -63,7 +63,7 @@ class DevToolsEyeDropper : public content::WebContentsObserver, ...@@ -63,7 +63,7 @@ class DevToolsEyeDropper : public content::WebContentsObserver,
content::RenderWidgetHost* host_; content::RenderWidgetHost* host_;
viz::mojom::FrameSinkVideoCapturerPtr video_capturer_; viz::mojom::FrameSinkVideoCapturerPtr video_capturer_;
mojo::Binding<viz::mojom::FrameSinkVideoConsumer> video_consumer_binding_; mojo::Binding<viz::mojom::FrameSinkVideoConsumer> video_consumer_binding_;
const bool enable_viz_; const bool use_video_capture_api_;
media::PaintCanvasVideoRenderer video_renderer_; media::PaintCanvasVideoRenderer video_renderer_;
base::WeakPtrFactory<DevToolsEyeDropper> weak_factory_; base::WeakPtrFactory<DevToolsEyeDropper> weak_factory_;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/tracing/tracing_controller_impl.h" #include "content/browser/tracing/tracing_controller_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/content_features.h"
#include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h" #include "services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation.h"
#include "services/tracing/public/mojom/constants.mojom.h" #include "services/tracing/public/mojom/constants.mojom.h"
...@@ -156,7 +157,9 @@ TracingHandler::TracingHandler(TracingHandler::Target target, ...@@ -156,7 +157,9 @@ TracingHandler::TracingHandler(TracingHandler::Target target,
return_as_stream_(false), return_as_stream_(false),
gzip_compression_(false), gzip_compression_(false),
weak_factory_(this) { weak_factory_(this) {
if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor)) { if (base::FeatureList::IsEnabled(features::kVizDisplayCompositor) ||
base::FeatureList::IsEnabled(
features::kUseVideoCaptureApiForDevToolsSnapshots)) {
frame_trace_recorder_ = frame_trace_recorder_ =
std::make_unique<DevToolsFrameTraceRecorderForViz>(); std::make_unique<DevToolsFrameTraceRecorderForViz>();
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/common/features.h"
#include "content/browser/bad_message.h" #include "content/browser/bad_message.h"
#include "content/browser/child_process_security_policy_impl.h" #include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/devtools/devtools_frame_trace_recorder.h" #include "content/browser/devtools/devtools_frame_trace_recorder.h"
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
#include "content/public/browser/render_widget_host_iterator.h" #include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/browser_side_navigation_policy.h" #include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_binding.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
...@@ -397,7 +399,12 @@ bool RenderFrameDevToolsAgentHost::AttachSession(DevToolsSession* session) { ...@@ -397,7 +399,12 @@ bool RenderFrameDevToolsAgentHost::AttachSession(DevToolsSession* session) {
session->AttachToAgent(agent_ptr_); session->AttachToAgent(agent_ptr_);
if (sessions().size() == 1) { if (sessions().size() == 1) {
frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder()); // Taking screenshots using the video capture API is done in TracingHandler.
if (!base::FeatureList::IsEnabled(features::kVizDisplayCompositor) &&
!base::FeatureList::IsEnabled(
features::kUseVideoCaptureApiForDevToolsSnapshots)) {
frame_trace_recorder_.reset(new DevToolsFrameTraceRecorder());
}
GrantPolicy(); GrantPolicy();
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
GetWakeLock()->RequestWakeLock(); GetWakeLock()->RequestWakeLock();
......
...@@ -416,6 +416,14 @@ const base::Feature kUseMojoAudioOutputStreamFactory{ ...@@ -416,6 +416,14 @@ const base::Feature kUseMojoAudioOutputStreamFactory{
const base::Feature kUserActivationV2{"UserActivationV2", const base::Feature kUserActivationV2{"UserActivationV2",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Use RenderWidgetHostView::CreateVideoCapturer instead of
// RenderWidgetHostView::CopyFromSurface to obtain a stream of snapshots
// captured from the renderer for DevTools performance timeline and eyedropper
// tool.
const base::Feature kUseVideoCaptureApiForDevToolsSnapshots{
"UseVideoCaptureApiForDevToolsSnapshots",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enables to use a snapshot file in creating V8 contexts. // Enables to use a snapshot file in creating V8 contexts.
const base::Feature kV8ContextSnapshot{"V8ContextSnapshot", const base::Feature kV8ContextSnapshot{"V8ContextSnapshot",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
......
...@@ -100,6 +100,8 @@ CONTENT_EXPORT extern const base::Feature kUseFeaturePolicyForPermissions; ...@@ -100,6 +100,8 @@ CONTENT_EXPORT extern const base::Feature kUseFeaturePolicyForPermissions;
CONTENT_EXPORT extern const base::Feature kUseMojoAudioInputStreamFactory; CONTENT_EXPORT extern const base::Feature kUseMojoAudioInputStreamFactory;
CONTENT_EXPORT extern const base::Feature kUseMojoAudioOutputStreamFactory; CONTENT_EXPORT extern const base::Feature kUseMojoAudioOutputStreamFactory;
CONTENT_EXPORT extern const base::Feature kUserActivationV2; CONTENT_EXPORT extern const base::Feature kUserActivationV2;
CONTENT_EXPORT extern const base::Feature
kUseVideoCaptureApiForDevToolsSnapshots;
CONTENT_EXPORT extern const base::Feature kV8ContextSnapshot; CONTENT_EXPORT extern const base::Feature kV8ContextSnapshot;
CONTENT_EXPORT extern const base::Feature kV8VmFuture; CONTENT_EXPORT extern const base::Feature kV8VmFuture;
CONTENT_EXPORT extern const base::Feature kVrWebInputEditing; CONTENT_EXPORT extern const base::Feature kVrWebInputEditing;
......
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