Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 498623002: aw: Avoid uncontrolled video context destruction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/in_process/synchronous_compositor_factory_impl.cc
diff --git a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
index 006a3c6e29efff014b75a4570f001feb709756f2..e624e9b53f01d80d69e0fe7b3c17f399c0cb489a 100644
--- a/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
+++ b/content/browser/android/in_process/synchronous_compositor_factory_impl.cc
@@ -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>();
hush (inactive) 2014/08/22 17:49:38 can we just return null here?
boliu 2014/08/22 17:54:17 Hmm, compiler seems happy, but not sure if it fits
boliu 2014/08/22 18:14:30 Took a cursory look and didn't find any instance o
hush (inactive) 2014/08/22 18:26:43 alright. lgtm sorry that I broke this thing... On
+ }
+
+ if (!video_context_provider_) {
DCHECK(service_);
DCHECK(share_context_.get());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698