Commit 2b20bcdd authored by kylechar's avatar kylechar Committed by Commit Bot

Revert "Add in-process VizCompositorThread for software compositing."

This reverts commit 7d8b7c2d.

Reason for revert: Need to revert https://crrev.com/c/1156998

Original change's description:
> Add in-process VizCompositorThread for software compositing.
> 
> We are having issues where starting a GPU process consistently fails on
> some systems. Currently OOP-D runs the display compositor in the GPU
> process always. This includes when both hardware acceleration and
> SwiftShader are disabled. If we can't start the GPU process, we can't
> run the display compositor and Chrome crashes.
> 
> This CL changes where the VizCompositorThread runs if the GPU access is
> disabled on Windows. We start the thread after giving up on the GPU
> process and create FrameSinkManagerImpl + dependencies on it.
> 
> Also fix chrome://gpu page so that OOP-D and surface sync features are
> still correct if |gpu_access_blocked| is true.
> 
> There is a lot of peripheral cleanup and code reuse possible as a follow
> up to this CL. It's not attempted here to make this easier to merge back
> to M69.
> 
> Bug: 849639
> Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
> Change-Id: Ica6a3ec5b0e7951cb6807b135df4b4cfe410e394
> Reviewed-on: https://chromium-review.googlesource.com/1158723
> Reviewed-by: Antoine Labour <piman@chromium.org>
> Commit-Queue: kylechar <kylechar@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#580241}

TBR=sadrul@chromium.org,kylechar@chromium.org,piman@chromium.org

Change-Id: I00fc978561630ef292436e2d44012a0931551d0f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 849639
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/1161121Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580264}
parent 3c2c21e2
......@@ -155,8 +155,6 @@ viz_component("service") {
"hit_test/hit_test_aggregator_delegate.h",
"hit_test/hit_test_manager.cc",
"hit_test/hit_test_manager.h",
"main/viz_compositor_thread_runner.cc",
"main/viz_compositor_thread_runner.h",
"surfaces/latest_local_surface_id_lookup_delegate.h",
"surfaces/referenced_surface_tracker.cc",
"surfaces/referenced_surface_tracker.h",
......
......@@ -15,23 +15,24 @@
#include "components/viz/service/display/display.h"
#include "components/viz/service/display/display_scheduler.h"
#include "components/viz/service/display_embedder/gl_output_surface.h"
#include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/display_embedder/skia_output_surface_impl.h"
#include "components/viz/service/display_embedder/software_output_surface.h"
#include "components/viz/service/display_embedder/viz_process_context_provider.h"
#include "components/viz/service/gl/gpu_service_impl.h"
#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/client/shared_memory_limits.h"
#include "gpu/command_buffer/service/image_factory.h"
#include "gpu/ipc/command_buffer_task_executor.h"
#include "gpu/ipc/common/surface_handle.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "gpu/ipc/service/gpu_channel_manager_delegate.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
#include "components/viz/service/display_embedder/gl_output_surface_win.h"
#include "components/viz/service/display_embedder/software_output_device_win.h"
#include "ui/gfx/win/rendering_window_manager.h"
#endif
#if defined(OS_ANDROID)
......@@ -57,44 +58,40 @@
#include "ui/ozone/public/surface_ozone_canvas.h"
#endif
namespace {
gpu::ImageFactory* GetImageFactory(gpu::GpuChannelManager* channel_manager) {
auto* buffer_factory = channel_manager->gpu_memory_buffer_factory();
return buffer_factory ? buffer_factory->AsImageFactory() : nullptr;
}
} // namespace
namespace viz {
GpuDisplayProvider::GpuDisplayProvider(
uint32_t restart_id,
GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor,
gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
gpu::ImageFactory* image_factory,
gpu::GpuChannelManager* gpu_channel_manager,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw)
: restart_id_(restart_id),
gpu_service_impl_(gpu_service_impl),
task_executor_(std::move(task_executor)),
gpu_channel_manager_delegate_(gpu_channel_manager_delegate),
gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
image_factory_(image_factory),
gpu_channel_manager_delegate_(gpu_channel_manager->delegate()),
gpu_memory_buffer_manager_(
std::make_unique<InProcessGpuMemoryBufferManager>(
gpu_channel_manager)),
image_factory_(GetImageFactory(gpu_channel_manager)),
server_shared_bitmap_manager_(server_shared_bitmap_manager),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
headless_(headless),
wait_for_all_pipeline_stages_before_draw_(
wait_for_all_pipeline_stages_before_draw) {}
GpuDisplayProvider::GpuDisplayProvider(
uint32_t restart_id,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw)
: GpuDisplayProvider(restart_id,
/*gpu_service_impl=*/nullptr,
/*task_executor=*/nullptr,
/*gpu_channel_manager_delegate=*/nullptr,
/*gpu_memory_buffer_manager=*/nullptr,
/*image_factory=*/nullptr,
server_shared_bitmap_manager,
headless,
wait_for_all_pipeline_stages_before_draw) {}
wait_for_all_pipeline_stages_before_draw) {
DCHECK_NE(restart_id_, BeginFrameSource::kNotRestartableId);
}
GpuDisplayProvider::~GpuDisplayProvider() = default;
......@@ -131,8 +128,6 @@ std::unique_ptr<Display> GpuDisplayProvider::CreateDisplay(
skia_output_surface = static_cast<SkiaOutputSurface*>(output_surface.get());
#endif
} else {
DCHECK(task_executor_);
scoped_refptr<VizProcessContextProvider> context_provider;
// Retry creating and binding |context_provider| on transient failures.
......@@ -214,19 +209,11 @@ GpuDisplayProvider::CreateSoftwareOutputDeviceForPlatform(
auto device = CreateSoftwareOutputDeviceWinGpu(
surface_handle, &output_device_backing_, display_client, &child_hwnd);
// If |child_hwnd| isn't null then a new child HWND was created.
// If |child_hwnd| isn't null then a new child HWND was created. Send an IPC
// to browser process for SetParent() syscall.
if (child_hwnd) {
if (gpu_channel_manager_delegate_) {
// Send an IPC to browser process for SetParent().
gpu_channel_manager_delegate_->SendCreatedChildWindow(surface_handle,
child_hwnd);
} else {
// We are already in the browser process.
if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(
surface_handle, child_hwnd)) {
LOG(ERROR) << "Bad parenting request.";
}
}
gpu_channel_manager_delegate_->SendCreatedChildWindow(surface_handle,
child_hwnd);
}
return device;
......
......@@ -23,9 +23,9 @@
#endif
namespace gpu {
class CommandBufferTaskExecutor;
class GpuChannelManager;
class GpuChannelManagerDelegate;
class GpuMemoryBufferManager;
class CommandBufferTaskExecutor;
class ImageFactory;
} // namespace gpu
......@@ -39,18 +39,10 @@ class SoftwareOutputDevice;
// In-process implementation of DisplayProvider.
class VIZ_SERVICE_EXPORT GpuDisplayProvider : public DisplayProvider {
public:
GpuDisplayProvider(
uint32_t restart_id,
GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> task_executor,
gpu::GpuChannelManagerDelegate* gpu_channel_manager_delegate,
std::unique_ptr<gpu::GpuMemoryBufferManager> gpu_memory_buffer_manager,
gpu::ImageFactory* image_factory,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw);
// Software compositing only.
GpuDisplayProvider(uint32_t restart_id,
GpuServiceImpl* gpu_service_impl,
scoped_refptr<gpu::CommandBufferTaskExecutor> gpu_service,
gpu::GpuChannelManager* gpu_channel_manager,
ServerSharedBitmapManager* server_shared_bitmap_manager,
bool headless,
bool wait_for_all_pipeline_stages_before_draw);
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/service/main/viz_compositor_thread_runner.h"
#include <utility>
#include "base/command_line.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "ui/gfx/switches.h"
namespace viz {
namespace {
const char kThreadName[] = "VizCompositorThread";
std::unique_ptr<base::Thread> CreateAndStartCompositorThread() {
auto thread = std::make_unique<base::Thread>(kThreadName);
base::Thread::Options thread_options;
#if defined(OS_WIN)
// Windows needs a UI message loop for child HWND. Other platforms can use the
// default message loop type.
thread_options.message_loop_type = base::MessageLoop::TYPE_UI;
#elif defined(OS_CHROMEOS)
thread_options.priority = base::ThreadPriority::DISPLAY;
#endif
CHECK(thread->StartWithOptions(thread_options));
return thread;
}
} // namespace
VizCompositorThreadRunner::VizCompositorThreadRunner()
: thread_(CreateAndStartCompositorThread()),
task_runner_(thread_->task_runner()) {}
VizCompositorThreadRunner::~VizCompositorThreadRunner() {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&VizCompositorThreadRunner::TearDownOnCompositorThread,
base::Unretained(this)));
thread_->Stop();
}
void VizCompositorThreadRunner::CreateFrameSinkManager(
mojom::FrameSinkManagerParamsPtr params) {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(
&VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread,
base::Unretained(this), std::move(params)));
}
void VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread(
mojom::FrameSinkManagerParamsPtr params) {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!frame_sink_manager_);
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
server_shared_bitmap_manager_ = std::make_unique<ServerSharedBitmapManager>();
base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
server_shared_bitmap_manager_.get(), "ServerSharedBitmapManager",
base::ThreadTaskRunnerHandle::Get());
// Create GpuDisplayProvider usable for software compositing only.
display_provider_ = std::make_unique<GpuDisplayProvider>(
params->restart_id, server_shared_bitmap_manager_.get(),
command_line->HasSwitch(switches::kHeadless),
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
base::Optional<uint32_t> activation_deadline_in_frames;
if (params->use_activation_deadline)
activation_deadline_in_frames = params->activation_deadline_in_frames;
frame_sink_manager_ = std::make_unique<FrameSinkManagerImpl>(
server_shared_bitmap_manager_.get(), activation_deadline_in_frames,
display_provider_.get());
frame_sink_manager_->BindAndSetClient(
std::move(params->frame_sink_manager), nullptr,
mojom::FrameSinkManagerClientPtr(
std::move(params->frame_sink_manager_client)));
}
void VizCompositorThreadRunner::TearDownOnCompositorThread() {
DCHECK(task_runner_->BelongsToCurrentThread());
if (server_shared_bitmap_manager_) {
base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
server_shared_bitmap_manager_.get());
}
frame_sink_manager_.reset();
display_provider_.reset();
server_shared_bitmap_manager_.reset();
}
} // namespace viz
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
#define COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/scoped_refptr.h"
#include "components/viz/service/viz_service_export.h"
#include "services/viz/privileged/interfaces/viz_main.mojom.h"
namespace base {
class SingleThreadTaskRunner;
class Thread;
} // namespace base
namespace viz {
class DisplayProvider;
class FrameSinkManagerImpl;
class ServerSharedBitmapManager;
// Starts and runs the VizCompositorThread. The thread will be started when this
// object is constructed. Objects on the thread will be initialized after
// calling CreateFrameSinkManager(). Destructor will teardown objects on thread
// and then stop the thread.
// TODO(kylechar): Convert VizMainImpl to use VizCompositorThreadRunner.
class VIZ_SERVICE_EXPORT VizCompositorThreadRunner {
public:
VizCompositorThreadRunner();
// Performs teardown on thread and then stops thread.
~VizCompositorThreadRunner();
// Create FrameSinkManager from |params|. This can be called from the thread
// that owns |this| to initialize state on VizCompositorThreadRunner.
void CreateFrameSinkManager(mojom::FrameSinkManagerParamsPtr params);
private:
void CreateFrameSinkManagerOnCompositorThread(
mojom::FrameSinkManagerParamsPtr params);
void TearDownOnCompositorThread();
// Start variables to be accessed only on |task_runner_|.
std::unique_ptr<ServerSharedBitmapManager> server_shared_bitmap_manager_;
std::unique_ptr<DisplayProvider> display_provider_;
std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_;
// End variables to be accessed only on |task_runner_|.
std::unique_ptr<base::Thread> thread_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(VizCompositorThreadRunner);
};
} // namespace viz
#endif // COMPONENTS_VIZ_SERVICE_MAIN_VIZ_COMPOSITOR_THREAD_RUNNER_H_
......@@ -16,7 +16,6 @@
#include "build/build_config.h"
#include "components/viz/common/switches.h"
#include "components/viz/service/display_embedder/gpu_display_provider.h"
#include "components/viz/service/display_embedder/in_process_gpu_memory_buffer_manager.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/gl/gpu_service_impl.h"
......@@ -333,17 +332,9 @@ void VizMainImpl::CreateFrameSinkManagerOnCompositorThread(
server_shared_bitmap_manager_.get(), "viz::ServerSharedBitmapManager",
base::ThreadTaskRunnerHandle::Get());
auto* gpu_channel_manager = gpu_service_->gpu_channel_manager();
gpu::ImageFactory* image_factory = nullptr;
if (gpu_channel_manager->gpu_memory_buffer_factory()) {
image_factory =
gpu_channel_manager->gpu_memory_buffer_factory()->AsImageFactory();
}
display_provider_ = std::make_unique<GpuDisplayProvider>(
params->restart_id, gpu_service_.get(), task_executor_,
gpu_channel_manager->delegate(),
std::make_unique<InProcessGpuMemoryBufferManager>(gpu_channel_manager),
image_factory, server_shared_bitmap_manager_.get(),
gpu_service_->gpu_channel_manager(), server_shared_bitmap_manager_.get(),
command_line->HasSwitch(switches::kHeadless),
command_line->HasSwitch(switches::kRunAllCompositorStagesBeforeDraw));
......
......@@ -16,7 +16,6 @@
#include "components/viz/client/local_surface_id_provider.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/gpu/raster_context_provider.h"
#include "components/viz/common/switches.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "components/viz/service/display_embedder/compositing_mode_reporter_impl.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
......@@ -153,47 +152,25 @@ void VizProcessTransportFactory::ConnectHostFrameSinkManager() {
std::move(frame_sink_manager_client_request), resize_task_runner(),
std::move(frame_sink_manager));
if (GpuDataManagerImpl::GetInstance()->GpuProcessStartAllowed()) {
// Hop to the IO thread, then send the other side of interface to viz
// process.
auto connect_on_io_thread =
[](viz::mojom::FrameSinkManagerRequest request,
viz::mojom::FrameSinkManagerClientPtrInfo client) {
// There should always be a GpuProcessHost instance, and GPU process,
// for running the compositor thread. The exception is during shutdown
// the GPU process won't be restarted and GpuProcessHost::Get() can
// return null.
auto* gpu_process_host = GpuProcessHost::Get();
if (gpu_process_host) {
gpu_process_host->ConnectFrameSinkManager(std::move(request),
std::move(client));
}
};
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(connect_on_io_thread,
std::move(frame_sink_manager_request),
frame_sink_manager_client.PassInterface()));
} else {
DCHECK(!viz_compositor_thread_);
// GPU process access is disabled. Start a new thread to run the display
// compositor in-process and connect HostFrameSinkManager to it.
viz_compositor_thread_ = std::make_unique<viz::VizCompositorThreadRunner>();
viz::mojom::FrameSinkManagerParamsPtr params =
viz::mojom::FrameSinkManagerParams::New();
params->restart_id = viz::BeginFrameSource::kNotRestartableId;
base::Optional<uint32_t> activation_deadline_in_frames =
switches::GetDeadlineToSynchronizeSurfaces();
params->use_activation_deadline = activation_deadline_in_frames.has_value();
params->activation_deadline_in_frames =
activation_deadline_in_frames.value_or(0u);
params->frame_sink_manager = std::move(frame_sink_manager_request);
params->frame_sink_manager_client =
frame_sink_manager_client.PassInterface();
viz_compositor_thread_->CreateFrameSinkManager(std::move(params));
}
// Hop to the IO thread, then send the other side of interface to viz process.
auto connect_on_io_thread =
[](viz::mojom::FrameSinkManagerRequest request,
viz::mojom::FrameSinkManagerClientPtrInfo client) {
// There should always be a GpuProcessHost instance, and GPU process,
// for running the compositor thread. The exception is during shutdown
// the GPU process won't be restarted and GpuProcessHost::Get() can
// return null.
auto* gpu_process_host = GpuProcessHost::Get();
if (gpu_process_host) {
gpu_process_host->ConnectFrameSinkManager(std::move(request),
std::move(client));
}
};
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(connect_on_io_thread,
std::move(frame_sink_manager_request),
frame_sink_manager_client.PassInterface()));
}
void VizProcessTransportFactory::CreateLayerTreeFrameSink(
......
......@@ -10,7 +10,6 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/context_lost_observer.h"
#include "components/viz/service/main/viz_compositor_thread_runner.h"
#include "content/browser/compositor/image_transport_factory.h"
#include "gpu/command_buffer/common/context_result.h"
#include "mojo/public/cpp/bindings/binding.h"
......@@ -129,10 +128,6 @@ class VizProcessTransportFactory : public ui::ContextFactory,
std::unique_ptr<cc::SingleThreadTaskGraphRunner> task_graph_runner_;
// Will start and run the VizCompositorThread for using an in-process display
// compositor.
std::unique_ptr<viz::VizCompositorThreadRunner> viz_compositor_thread_;
base::WeakPtrFactory<VizProcessTransportFactory> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(VizProcessTransportFactory);
......
......@@ -223,14 +223,8 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl(
const GpuFeatureData gpu_feature_data =
GetGpuFeatureData(gpu_feature_info, type, i, &eof);
std::string status;
if (gpu_feature_data.name == "surface_synchronization") {
status = (features::IsSurfaceSynchronizationEnabled() ? "enabled_on"
: "disabled_off");
} else if (gpu_feature_data.name == "viz_display_compositor") {
status = (features::IsVizDisplayCompositorEnabled() ? "enabled_on"
: "disabled_off");
} else if (gpu_feature_data.disabled || gpu_access_blocked ||
gpu_feature_data.status == gpu::kGpuFeatureStatusDisabled) {
if (gpu_feature_data.disabled || gpu_access_blocked ||
gpu_feature_data.status == gpu::kGpuFeatureStatusDisabled) {
status = "disabled";
if (gpu_feature_data.fallback_to_software)
status += "_software";
......@@ -258,6 +252,14 @@ std::unique_ptr<base::DictionaryValue> GetFeatureStatusImpl(
status += "_force";
status += "_on";
}
if (gpu_feature_data.name == "surface_synchronization") {
if (features::IsSurfaceSynchronizationEnabled())
status += "_on";
}
if (gpu_feature_data.name == "viz_display_compositor") {
if (features::IsVizDisplayCompositorEnabled())
status += "_on";
}
if (gpu_feature_data.name == "skia_renderer") {
if (features::IsUsingSkiaRenderer())
status += "_on";
......
......@@ -353,19 +353,7 @@ bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const {
}
bool GpuDataManagerImplPrivate::GpuProcessStartAllowed() const {
if (GpuAccessAllowed(nullptr))
return true;
#if defined(USE_X11) || defined(OS_MACOSX)
// If GPU access is disabled with OOP-D we run the display compositor in:
// Browser process: Windows
// GPU process: Linux and Mac
// N/A: Android and Chrome OS (GPU access can't be disabled)
if (features::IsVizDisplayCompositorEnabled())
return true;
#endif
return false;
return features::IsVizDisplayCompositorEnabled() || GpuAccessAllowed(nullptr);
}
void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() {
......
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