diff options
author | Dan Stoza <stoza@google.com> | 2015-05-14 09:27:25 -0700 |
---|---|---|
committer | Dan Stoza <stoza@google.com> | 2015-05-14 10:43:07 -0700 |
commit | 59bfd2bbed9576ecdfc01720ca47215c47d7475a (patch) | |
tree | 67cfd0e06030cb19d3a2ffba28c30839ef6a4697 /services/surfaceflinger | |
parent | 9188b4bb5d44c219face5a4c1c681700cc838294 (diff) | |
download | frameworks_native-59bfd2bbed9576ecdfc01720ca47215c47d7475a.zip frameworks_native-59bfd2bbed9576ecdfc01720ca47215c47d7475a.tar.gz frameworks_native-59bfd2bbed9576ecdfc01720ca47215c47d7475a.tar.bz2 |
SurfaceFlinger: Handle EGL errors more cleanly
Adds some more safety checking for cases where we get an error while
trying to create the EGLImage. The checking puts the Layer into a
failed state after detecting an error, since the shadow queue may no
longer be synchronized.
Bug: 20957332
Change-Id: I68b4c40eab3e58731b875ed5752f2c7d17f14bcb
(cherry picked from commit 65476f3332641066a99e22338bf5cf49ce4af642)
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 21 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.h | 1 |
2 files changed, 21 insertions, 1 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 2b733e9..8d8af52 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -84,7 +84,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, mQueueItemLock(), mQueueItemCondition(), mQueueItems(), - mLastFrameNumberReceived(0) + mLastFrameNumberReceived(0), + mUpdateTexImageFailed(false) { mCurrentCrop.makeInvalid(); mFlinger->getRenderEngine().genTextures(1, &mTextureName); @@ -1314,6 +1315,24 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions) mQueueItems.removeAt(0); android_atomic_dec(&mQueuedFrames); return outDirtyRegion; + } else if (updateResult != NO_ERROR || mUpdateTexImageFailed) { + // This can occur if something goes wrong when trying to create the + // EGLImage for this buffer. If this happens, the buffer has already + // been released, so we need to clean up the queue and bug out + // early. + { + Mutex::Autolock lock(mQueueItemLock); + mQueueItems.clear(); + android_atomic_and(0, &mQueuedFrames); + } + + // Once we have hit this state, the shadow queue may no longer + // correctly reflect the incoming BufferQueue's contents, so even if + // updateTexImage starts working, the only safe course of action is + // to continue to ignore updates. + mUpdateTexImageFailed = true; + + return outDirtyRegion; } { // Autolock scope diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 947da85..4e222b7 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -419,6 +419,7 @@ private: Condition mQueueItemCondition; Vector<BufferItem> mQueueItems; uint64_t mLastFrameNumberReceived; + bool mUpdateTexImageFailed; // This is only modified from the main thread }; // --------------------------------------------------------------------------- |