Skip to content

Commit e88ca71

Browse files
camaelonAndroid (Google) Code Review
authored andcommitted
Merge "Hack to workaround the fact that the EGL context can be removed from under us by framework in low memory condition." into ics-mr1
2 parents 302afb9 + 2bc0b01 commit e88ca71

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

@@ -4225,6 +4233,13 @@ protected void onDraw(Canvas canvas) {
42254233
}
42264234

42274235
if (canvas.isHardwareAccelerated()) {
4236+
if (mIncrementEGLContextHack == false) {
4237+
mIncrementEGLContextHack = true;
4238+
EGL10 egl = (EGL10) EGLContext.getEGL();
4239+
EGLDisplay eglDisplay = egl.eglGetDisplay(EGL_DEFAULT_DISPLAY);
4240+
int[] version = new int[2];
4241+
egl.eglInitialize(eglDisplay, version);
4242+
}
42284243
mZoomManager.setHardwareAccelerated();
42294244
}
42304245

0 commit comments

Comments
 (0)