Commit cb81131b authored by boliu@chromium.org's avatar boliu@chromium.org

aw: Avoid uncontrolled video context destruction

Since r289474, the sync factory nulls out the video context
which means the destruction is uncontrolled. Context
destruction is synchronous, so can cause deadlocks if there
are not webviews attached to view tree to run GL.

This is a rewrite of r289474 that just returns null
VideoContextProvider if no webview is ready to use it. But
still hold on to the reference to the context to avoid
destruction.

BUG=403882

Review URL: https://codereview.chromium.org/498623002

Cr-Commit-Position: refs/heads/master@{#291527}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291527 0039d316-1c4b-4281-b951-d872f2087c98
parent 10288a72
......@@ -232,11 +232,6 @@ void SynchronousCompositorFactoryImpl::CompositorReleasedHardwareDraw() {
base::AutoLock lock(num_hardware_compositor_lock_);
DCHECK_GT(num_hardware_compositors_, 0u);
num_hardware_compositors_--;
if (num_hardware_compositors_ == 0) {
// Nullify the video_context_provider_ now so that it is not null only if
// there is at least 1 hardware compositor
video_context_provider_ = NULL;
}
}
bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
......@@ -246,13 +241,16 @@ bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
context_provider;
// This check only guarantees the main thread context is created after
// a compositor did successfully initialize hardware draw in the past.
// When all compositors have released hardware draw, main thread context
// creation is guaranteed to fail.
if (CanCreateMainThreadContext() && !video_context_provider_) {
// Always fail creation even if |video_context_provider_| is not NULL.
// This is to avoid synchronous calls that may deadlock. Setting
// |video_context_provider_| to null is also not safe since it makes
// synchronous destruction uncontrolled and possibly deadlock.
if (!CanCreateMainThreadContext()) {
return
scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>();
}
if (!video_context_provider_) {
DCHECK(service_);
DCHECK(share_context_.get());
......
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