From 17035b0211a3c9d45ea46a99217a6acbe76e8fbe Mon Sep 17 00:00:00 2001 From: John Reck Date: Wed, 3 Sep 2014 07:39:53 -0700 Subject: Have destroy call freePrefetchedLayers Bug: 17208461 There's a potential race condition between HardwareRenderer.destroy() being called (which calls destroyCanvasAndSurface()) and the renderer being finalized (which is what calls freePrefetchedLayers), during which time it's possible we get a TRIM_MEMORY_COMPLETE and destroy the EGL context. Fix this race condition by moving stopDrawing() and freePrefetchedLayers() into destroyCanvasAndSurface() where they should have been in the first place. Also, if we hit the assertion failure, dump the current state of Caches to try and provide more context for the failure. Change-Id: Ife0ba3562041e8b08e87e3e13640472b3004eed6 --- libs/hwui/RenderState.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libs/hwui/RenderState.cpp') diff --git a/libs/hwui/RenderState.cpp b/libs/hwui/RenderState.cpp index 50b8f395011c..9948b44ac703 100644 --- a/libs/hwui/RenderState.cpp +++ b/libs/hwui/RenderState.cpp @@ -32,10 +32,14 @@ void RenderState::onGLContextCreated() { // This is delayed because the first access of Caches makes GL calls mCaches = &Caches::getInstance(); mCaches->init(); + mCaches->setRenderState(this); } void RenderState::onGLContextDestroyed() { - LOG_ALWAYS_FATAL_IF(!mActiveLayers.empty(), "layers have survived gl context destruction"); + if (CC_UNLIKELY(!mActiveLayers.empty())) { + mCaches->dumpMemoryUsage(); + LOG_ALWAYS_FATAL("layers have survived gl context destruction"); + } } void RenderState::setViewport(GLsizei width, GLsizei height) { -- cgit v1.2.3-59-g8ed1b