Commit 9a26ee29 authored by Weiliang Chen's avatar Weiliang Chen Committed by Commit Bot

viz: Wait for Creation of OverlayProcessorOnGpu before Using It

The creation of OverlayProcessorOnGpu is not synchronous, and we might
try to use it before the task is run on the gpu thread. Make sure to
wait for the creation if we try to use it.


R=rjkroege

Bug: 1044671
Change-Id: I9c9f02368ab36b3e328a525612f4fbd481e6df97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015345
Commit-Queue: weiliangc <weiliangc@chromium.org>
Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735076}
parent 2e39cd54
......@@ -4,7 +4,6 @@
#include "components/viz/service/display/overlay_processor_android.h"
#include "base/synchronization/waitable_event.h"
#include "components/viz/common/quads/stream_video_draw_quad.h"
#include "components/viz/service/display/display_resource_provider.h"
#include "components/viz/service/display/overlay_processor_on_gpu.h"
......@@ -67,6 +66,7 @@ void OverlayProcessorAndroid::InitializeOverlayProcessorOnGpu(
gpu::SharedImageManager* shared_image_manager) {
processor_on_gpu_ =
std::make_unique<OverlayProcessorOnGpu>(shared_image_manager);
gpu_init_event_.Signal();
}
void OverlayProcessorAndroid::DestroyOverlayProcessorOnGpu(
......@@ -102,6 +102,10 @@ void OverlayProcessorAndroid::ScheduleOverlays(
for (auto& read_lock : locks)
locks_sync_tokens.push_back(read_lock->sync_token());
// If we haven't finished creating processor_on_gpu_, wait for it.
if (!processor_on_gpu_ && able_to_create_processor_on_gpu_)
gpu_init_event_.Wait();
auto task = base::BindOnce(&OverlayProcessorOnGpu::ScheduleOverlays,
base::Unretained(processor_on_gpu_.get()),
std::move(overlay_candidates_));
......@@ -208,6 +212,10 @@ void OverlayProcessorAndroid::NotifyOverlayPromotion(
locks_sync_tokens.push_back(read_lock->sync_token());
if (gpu_task_scheduler_) {
// If we haven't finished creating processor_on_gpu_, wait for it.
if (!processor_on_gpu_ && able_to_create_processor_on_gpu_)
gpu_init_event_.Wait();
auto task = base::BindOnce(&OverlayProcessorOnGpu::NotifyOverlayPromotions,
base::Unretained(processor_on_gpu_.get()),
std::move(promotion_denied),
......
......@@ -5,6 +5,7 @@
#ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_ANDROID_H_
#define COMPONENTS_VIZ_SERVICE_DISPLAY_OVERLAY_PROCESSOR_ANDROID_H_
#include "base/synchronization/waitable_event.h"
#include "components/viz/service/display/overlay_processor_using_strategy.h"
namespace base {
......@@ -76,6 +77,9 @@ class VIZ_SERVICE_EXPORT OverlayProcessorAndroid
bool able_to_create_processor_on_gpu_ = false;
// This class is created, accessed, and destroyed on the gpu thread.
std::unique_ptr<OverlayProcessorOnGpu> processor_on_gpu_;
base::WaitableEvent gpu_init_event_{
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED};
OverlayCandidateList overlay_candidates_;
};
......
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