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

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 654623002: aw: Check compositor pointer before use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: android_webview/browser/browser_view_renderer.cc
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index 8f21b165d17d91346f9c07a9730ef1caccb8c64f..579fc117cbfd144791b41b39304c81e302d39c2d 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -145,6 +145,9 @@ void BrowserViewRenderer::TrimMemory(const int level, const bool visible) {
TRIM_MEMORY_BACKGROUND = 40,
};
+ if (!compositor_ || !hardware_enabled_)
+ return;
+
// Not urgent enough. TRIM_MEMORY_UI_HIDDEN is treated specially because
// it does not indicate memory pressure, but merely that the app is
// backgrounded.
@@ -192,6 +195,7 @@ BrowserViewRenderer::CalculateDesiredMemoryPolicy() {
// well as the tile resource allocation in GlobalTileManager.
void BrowserViewRenderer::RequestMemoryPolicy(
SynchronousCompositorMemoryPolicy& new_policy) {
+ DCHECK(compositor_);
GlobalTileManager* manager = GlobalTileManager::GetInstance();
// The following line will call BrowserViewRenderer::SetMemoryPolicy().
@@ -317,6 +321,7 @@ void BrowserViewRenderer::UpdateParentDrawConstraints() {
void BrowserViewRenderer::ReturnUnusedResource(
scoped_ptr<cc::CompositorFrame> frame) {
+ DCHECK(compositor_);
if (!frame.get())
return;
@@ -328,6 +333,7 @@ void BrowserViewRenderer::ReturnUnusedResource(
}
void BrowserViewRenderer::ReturnResourceFromParent() {
+ DCHECK(compositor_);
cc::CompositorFrameAck frame_ack;
shared_renderer_state_->SwapReturnedResources(&frame_ack.resources);
if (!frame_ack.resources.empty()) {
@@ -456,6 +462,7 @@ void BrowserViewRenderer::OnDetachedFromWindow() {
}
void BrowserViewRenderer::ReleaseHardware() {
+ DCHECK(compositor_);
DCHECK(hardware_enabled_);
ReturnUnusedResource(shared_renderer_state_->PassCompositorFrame());
ReturnResourceFromParent();
@@ -491,9 +498,10 @@ void BrowserViewRenderer::DidDestroyCompositor(
content::SynchronousCompositor* compositor) {
TRACE_EVENT0("android_webview", "BrowserViewRenderer::DidDestroyCompositor");
DCHECK(compositor_);
- compositor_ = NULL;
SynchronousCompositorMemoryPolicy zero_policy;
- DCHECK(memory_policy_ == zero_policy);
+ RequestMemoryPolicy(zero_policy);
+ compositor_ = NULL;
+ hardware_enabled_ = false;
boliu 2014/10/17 22:59:26 oh god that's so freaking wrong
hush (inactive) 2014/10/17 23:04:15 what do you mean? I thought what you did is replac
boliu 2014/10/17 23:06:01 CHECK was to see it actually happens, not the fix.
}
void BrowserViewRenderer::SetContinuousInvalidate(bool invalidate) {
« 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