Skip to content

Commit 2bc0b01

Browse files
committed
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
1 parent 030bb99 commit 2bc0b01

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/java/android/webkit/WebView.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@
119119
import java.util.regex.Matcher;
120120
import java.util.regex.Pattern;
121121

122+
import javax.microedition.khronos.egl.EGL10;
123+
import javax.microedition.khronos.egl.EGLContext;
124+
import javax.microedition.khronos.egl.EGLDisplay;
125+
import static javax.microedition.khronos.egl.EGL10.*;
126+
122127
/**
123128
* <p>A View that displays web pages. This class is the basis upon which you
124129
* can roll your own web browser or simply display some online content within your Activity.
@@ -909,6 +914,9 @@ public void onTrimMemory(int level) {
909914
private Rect mScrollingLayerBounds = new Rect();
910915
private boolean mSentAutoScrollMessage = false;
911916

917+
// Temporary hack to work around the context removal upon memory pressure
918+
private static boolean mIncrementEGLContextHack = false;
919+
912920
// used for serializing asynchronously handled touch events.
913921
private final TouchEventQueue mTouchEventQueue = new TouchEventQueue();
914922

@@ -4213,6 +4221,13 @@ protected void onDraw(Canvas canvas) {
42134221
}
42144222

42154223
if (canvas.isHardwareAccelerated()) {
4224+
if (mIncrementEGLContextHack == false) {
4225+
mIncrementEGLContextHack = true;
4226+
EGL10 egl = (EGL10) EGLContext.getEGL();
4227+
EGLDisplay eglDisplay = egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
4228+
int[] version = new int[2];
4229+
egl.eglInitialize(eglDisplay, version);
4230+
}
42164231
mZoomManager.setHardwareAccelerated();
42174232
}
42184233

0 commit comments

Comments
 (0)