diff options
author | Bo Liu <boliu@google.com> | 2014-12-17 16:55:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-12-17 16:55:32 +0000 |
commit | fabffb1485867d359bfe2149faee72efe4df2f48 (patch) | |
tree | fce94495d35ec2256f76d4a816dc1e3deb2aca49 | |
parent | 83109aa23599e63402ee03cd93f67d3ff874e241 (diff) | |
parent | 141411bccb8ff5f5d56bf79c8d7f911318a7c086 (diff) | |
download | chromium_org-fabffb1485867d359bfe2149faee72efe4df2f48.tar.gz |
Merge "Cherry-pick: Don't schedule more invokeFunctors than necessary." into m39
-rw-r--r-- | android_webview/browser/shared_renderer_state.cc | 14 | ||||
-rw-r--r-- | android_webview/native/aw_contents.cc | 20 |
2 files changed, 23 insertions, 11 deletions
diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc index 0de8371b1c..b880ce00ad 100644 --- a/android_webview/browser/shared_renderer_state.cc +++ b/android_webview/browser/shared_renderer_state.cc @@ -18,8 +18,8 @@ class RequestDrawGLTracker { RequestDrawGLTracker(); bool ShouldRequestOnNoneUiThread(SharedRendererState* state); bool ShouldRequestOnUiThread(SharedRendererState* state); - void DidRequestOnUiThread(); void ResetPending(); + void SetQueuedFunctorOnUi(SharedRendererState* state); private: base::Lock lock_; @@ -46,6 +46,9 @@ bool RequestDrawGLTracker::ShouldRequestOnUiThread(SharedRendererState* state) { pending_non_ui_->ResetRequestDrawGLCallback(); pending_non_ui_ = NULL; } + // At this time, we could have already called RequestDrawGL on the UI thread, + // but the corresponding GL mode process hasn't happened yet. In this case, + // don't schedule another requestDrawGL on the UI thread. if (pending_ui_) return false; pending_ui_ = state; @@ -58,6 +61,14 @@ void RequestDrawGLTracker::ResetPending() { pending_ui_ = NULL; } +void RequestDrawGLTracker::SetQueuedFunctorOnUi(SharedRendererState* state) { + base::AutoLock lock(lock_); + DCHECK(state); + DCHECK(pending_ui_ == state || pending_non_ui_ == state); + pending_ui_ = state; + pending_non_ui_ = NULL; +} + } // namespace internal namespace { @@ -119,6 +130,7 @@ void SharedRendererState::ResetRequestDrawGLCallback() { void SharedRendererState::ClientRequestDrawGLOnUIThread() { DCHECK(ui_loop_->BelongsToCurrentThread()); ResetRequestDrawGLCallback(); + g_request_draw_gl_tracker.Get().SetQueuedFunctorOnUi(this); if (!client_on_ui_->RequestDrawGL(NULL, false)) { g_request_draw_gl_tracker.Get().ResetPending(); LOG(ERROR) << "Failed to request GL process. Deadlock likely"; diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc index 4addcab196..f05bd31106 100644 --- a/android_webview/native/aw_contents.cc +++ b/android_webview/native/aw_contents.cc @@ -353,6 +353,16 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) { return; } + // kModeProcessNoContext should never happen because we tear down hardware + // in onTrimMemory. However that guarantee is maintained outside of chromium + // code. Not notifying shared state in kModeProcessNoContext can lead to + // immediate deadlock, which is slightly more catastrophic than leaks or + // corruption. + if (draw_info->mode == AwDrawGLInfo::kModeProcess || + draw_info->mode == AwDrawGLInfo::kModeProcessNoContext) { + shared_renderer_state_.DidDrawGLProcess(); + } + { GLViewRendererManager* manager = GLViewRendererManager::GetInstance(); base::AutoLock lock(render_thread_lock_); @@ -371,16 +381,6 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) { LOG(ERROR) << "Received unexpected kModeProcessNoContext"; } - // kModeProcessNoContext should never happen because we tear down hardware - // in onTrimMemory. However that guarantee is maintained outside of chromium - // code. Not notifying shared state in kModeProcessNoContext can lead to - // immediate deadlock, which is slightly more catastrophic than leaks or - // corruption. - if (draw_info->mode == AwDrawGLInfo::kModeProcess || - draw_info->mode == AwDrawGLInfo::kModeProcessNoContext) { - shared_renderer_state_.DidDrawGLProcess(); - } - if (shared_renderer_state_.IsInsideHardwareRelease()) { hardware_renderer_.reset(); // Flush the idle queue in tear down. |