From 2bc0b01ffe481af877de312f3a87fa769642d2f4 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Wed, 16 Nov 2011 19:26:25 -0800 Subject: [PATCH] Hack to workaround the fact that the EGL context can be removed from under us by framework in low memory condition. bug:5627977 Change-Id: I3c138985e3e6c16f7c15497a1a11ffed93cd8e78 --- core/java/android/webkit/WebView.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 7249497120b20..0f75cc7736911 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -119,6 +119,11 @@ import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.microedition.khronos.egl.EGL10; +import javax.microedition.khronos.egl.EGLContext; +import javax.microedition.khronos.egl.EGLDisplay; +import static javax.microedition.khronos.egl.EGL10.*; + /** *

A View that displays web pages. This class is the basis upon which you * can roll your own web browser or simply display some online content within your Activity. @@ -909,6 +914,9 @@ public class WebView extends AbsoluteLayout private Rect mScrollingLayerBounds = new Rect(); private boolean mSentAutoScrollMessage = false; + // Temporary hack to work around the context removal upon memory pressure + private static boolean mIncrementEGLContextHack = false; + // used for serializing asynchronously handled touch events. private final TouchEventQueue mTouchEventQueue = new TouchEventQueue(); @@ -4213,6 +4221,13 @@ public class WebView extends AbsoluteLayout } if (canvas.isHardwareAccelerated()) { + if (mIncrementEGLContextHack == false) { + mIncrementEGLContextHack = true; + EGL10 egl = (EGL10) EGLContext.getEGL(); + EGLDisplay eglDisplay = egl.eglGetDisplay(EGL_DEFAULT_DISPLAY); + int[] version = new int[2]; + egl.eglInitialize(eglDisplay, version); + } mZoomManager.setHardwareAccelerated(); }