diff options
author | Jack Palevich <jackpal@google.com> | 2013-03-18 22:44:58 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2013-03-18 22:55:27 -0700 |
commit | ea62b95e7c562e8d0052441d8a0d7de6d919320f (patch) | |
tree | 28a4b3e40da88b483dd59451b72b240f83224108 /opengl/java | |
parent | ab7409e6376708cf8958f3cfb8f6fce2e7bfc69c (diff) | |
download | frameworks_base-ea62b95e7c562e8d0052441d8a0d7de6d919320f.zip frameworks_base-ea62b95e7c562e8d0052441d8a0d7de6d919320f.tar.gz frameworks_base-ea62b95e7c562e8d0052441d8a0d7de6d919320f.tar.bz2 |
Fix createSurface / eglCreateWindowSurface race.
Previously we could have returned from createSurface on the main thread
before calling eglCreateWindowSurface on the GLThread. That could lead
to a problem because the surface could be destroyed before
eglCreateWindowSurface got a chance to run.
Bug: 8328715
Change-Id: I273149f7d4b165abbe218a91ff54083f3f498cb0
Diffstat (limited to 'opengl/java')
-rw-r--r-- | opengl/java/android/opengl/GLSurfaceView.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java index 54dcaaa..5a2e261 100644 --- a/opengl/java/android/opengl/GLSurfaceView.java +++ b/opengl/java/android/opengl/GLSurfaceView.java @@ -1445,6 +1445,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback Log.i("GLThread", "waiting tid=" + getId() + " mHaveEglContext: " + mHaveEglContext + " mHaveEglSurface: " + mHaveEglSurface + + " mFinishedCreatingEglSurface: " + mFinishedCreatingEglSurface + " mPaused: " + mPaused + " mHasSurface: " + mHasSurface + " mSurfaceIsBad: " + mSurfaceIsBad @@ -1468,8 +1469,14 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback if (LOG_SURFACE) { Log.w("GLThread", "egl createSurface"); } - if (!mEglHelper.createSurface()) { + if (mEglHelper.createSurface()) { synchronized(sGLThreadManager) { + mFinishedCreatingEglSurface = true; + sGLThreadManager.notifyAll(); + } + } else { + synchronized(sGLThreadManager) { + mFinishedCreatingEglSurface = true; mSurfaceIsBad = true; sGLThreadManager.notifyAll(); } @@ -1595,8 +1602,11 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback Log.i("GLThread", "surfaceCreated tid=" + getId()); } mHasSurface = true; + mFinishedCreatingEglSurface = false; sGLThreadManager.notifyAll(); - while((mWaitingForSurface) && (!mExited)) { + while (mWaitingForSurface + && !mFinishedCreatingEglSurface + && !mExited) { try { sGLThreadManager.wait(); } catch (InterruptedException e) { @@ -1735,6 +1745,7 @@ public class GLSurfaceView extends SurfaceView implements SurfaceHolder.Callback private boolean mWaitingForSurface; private boolean mHaveEglContext; private boolean mHaveEglSurface; + private boolean mFinishedCreatingEglSurface; private boolean mShouldReleaseEglContext; private int mWidth; private int mHeight; |