Commit b6eb9cd8 authored by CJ DiMeglio's avatar CJ DiMeglio Committed by Commit Bot

Ensures dereference of |video_frame_compositor_context_provider_| on proper thread.

This CL makes sure that the |video_frame_compositor_context_provider_|
and references to it get dereferenced to the thread it is bound to (in
this case, the |video_frame_compositor_task_runner_|

Bug: 898989
Change-Id: I98654bb5a6b29a43a384ce0308b4b97d575903a0
Reviewed-on: https://chromium-review.googlesource.com/c/1303178
Commit-Queue: CJ DiMeglio <lethalantidote@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605878}
parent bbf5b85e
...@@ -230,6 +230,10 @@ std::unique_ptr<blink::WebVideoFrameSubmitter> MediaFactory::CreateSubmitter( ...@@ -230,6 +230,10 @@ std::unique_ptr<blink::WebVideoFrameSubmitter> MediaFactory::CreateSubmitter(
? render_thread->compositor_task_runner() ? render_thread->compositor_task_runner()
: render_frame_->GetTaskRunner( : render_frame_->GetTaskRunner(
blink::TaskType::kInternalMediaRealTime); blink::TaskType::kInternalMediaRealTime);
// TODO(https://crbug/901513): Remove once kOnDemand is removed.
render_thread->SetVideoFrameCompositorTaskRunner(
*video_frame_compositor_task_runner);
} }
std::unique_ptr<blink::WebVideoFrameSubmitter> submitter; std::unique_ptr<blink::WebVideoFrameSubmitter> submitter;
......
...@@ -1001,6 +1001,14 @@ void RenderThreadImpl::Init() { ...@@ -1001,6 +1001,14 @@ void RenderThreadImpl::Init() {
RenderThreadImpl::~RenderThreadImpl() { RenderThreadImpl::~RenderThreadImpl() {
g_main_task_runner.Get() = nullptr; g_main_task_runner.Get() = nullptr;
// Need to make sure this reference is removed on the correct task runner;
if (video_frame_compositor_task_runner_ &&
video_frame_compositor_context_provider_) {
video_frame_compositor_context_provider_->AddRef();
video_frame_compositor_task_runner_->ReleaseSoon(
FROM_HERE, std::move(video_frame_compositor_context_provider_).get());
}
} }
void RenderThreadImpl::Shutdown() { void RenderThreadImpl::Shutdown() {
...@@ -1367,12 +1375,21 @@ media::GpuVideoAcceleratorFactories* RenderThreadImpl::GetGpuFactories() { ...@@ -1367,12 +1375,21 @@ media::GpuVideoAcceleratorFactories* RenderThreadImpl::GetGpuFactories() {
scoped_refptr<viz::ContextProvider> scoped_refptr<viz::ContextProvider>
RenderThreadImpl::GetVideoFrameCompositorContextProvider( RenderThreadImpl::GetVideoFrameCompositorContextProvider(
scoped_refptr<viz::ContextProvider> unwanted_context_provider) { scoped_refptr<viz::ContextProvider> unwanted_context_provider) {
DCHECK(video_frame_compositor_task_runner_);
if (video_frame_compositor_context_provider_ && if (video_frame_compositor_context_provider_ &&
video_frame_compositor_context_provider_ != unwanted_context_provider) { video_frame_compositor_context_provider_ != unwanted_context_provider) {
return video_frame_compositor_context_provider_; return video_frame_compositor_context_provider_;
} }
video_frame_compositor_context_provider_ = nullptr; // Need to make sure these references are removed on the correct task runner;
if (video_frame_compositor_context_provider_) {
video_frame_compositor_context_provider_->AddRef();
viz::ContextProvider* context_provider_ptr =
video_frame_compositor_context_provider_.get();
video_frame_compositor_context_provider_ = nullptr;
video_frame_compositor_task_runner_->ReleaseSoon(FROM_HERE,
context_provider_ptr);
}
scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = scoped_refptr<gpu::GpuChannelHost> gpu_channel_host =
EstablishGpuChannelSync(); EstablishGpuChannelSync();
......
...@@ -504,6 +504,14 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -504,6 +504,14 @@ class CONTENT_EXPORT RenderThreadImpl
scoped_refptr<base::SingleThreadTaskRunner> scoped_refptr<base::SingleThreadTaskRunner>
CreateVideoFrameCompositorTaskRunner(); CreateVideoFrameCompositorTaskRunner();
// In the case of kOnDemand, we wont be using the task_runner created in
// CreateVideoFrameCompositorTaskRunner.
// TODO(https://crbug/901513): Remove once kOnDemand is removed.
void SetVideoFrameCompositorTaskRunner(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
video_frame_compositor_task_runner_ = task_runner;
}
private: private:
void OnProcessFinalRelease() override; void OnProcessFinalRelease() override;
// IPC::Listener // IPC::Listener
......
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