From e1dfe84b38ed080c7bb7ac00fd9e3c6c590a147d Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Wed, 25 Jan 2012 14:25:28 -0800 Subject: Clean up tranfer queue before EGL context destroy This will avoid ANR when texture generation thread is stuck b/c transfer queue is running out of slots, at the same time, EGL context get destroyed and no more draw call coming to free up more slots. Abandon the surface texture will also help to be more memory friendly. Move the highEndGfx check to TilesManager. bug:5639899 Change-Id: I98f0289ae5ca18361f71dec853327223506e3073 --- Source/WebKit/android/nav/WebView.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Source/WebKit/android/nav/WebView.cpp') diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 78881a9..6c49bb7 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -450,8 +450,9 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, return false; if (!m_glWebViewState) { + TilesManager::instance()->setHighEndGfx(m_isHighEndGfx); + m_glWebViewState = new GLWebViewState(); - m_glWebViewState->setHighEndGfx(m_isHighEndGfx); m_glWebViewState->glExtras()->setCursorRingExtra(&m_ring); m_glWebViewState->glExtras()->setFindOnPageExtra(&m_findOnPage); if (m_baseLayer->content()) { @@ -2640,6 +2641,14 @@ static jstring nativeGetProperty(JNIEnv *env, jobject obj, jstring jkey) static void nativeOnTrimMemory(JNIEnv *env, jobject obj, jint level) { if (TilesManager::hardwareAccelerationEnabled()) { + // When we got TRIM_MEMORY_MODERATE or TRIM_MEMORY_COMPLETE, we should + // make sure the transfer queue is empty and then abandon the Surface + // Texture to avoid ANR b/c framework may destroy the EGL context. + // Refer to WindowManagerImpl.java for conditions we followed. + if (level >= TRIM_MEMORY_MODERATE + && !TilesManager::instance()->highEndGfx()) + TilesManager::instance()->transferQueue()->emptyQueue(); + bool freeAllTextures = (level > TRIM_MEMORY_UI_HIDDEN), glTextures = true; TilesManager::instance()->discardTextures(freeAllTextures, glTextures); } -- cgit v1.1