From dddcd22b7ea56b1d3e31f2bbc35c80cb047de879 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Fri, 18 May 2012 15:33:57 -0700 Subject: [PATCH] Don't crash on Surface.unlockAndPost() but log & try again Bug #6482593 Change-Id: Ib477b58e2b7a6cb19a87d05f2aa0448e04d82f7c --- core/java/android/view/ViewRootImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index d9e35453468c3..90179ff8feeb5 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2257,7 +2257,7 @@ public final class ViewRootImpl implements ViewParent, mLayoutRequested = true; // ask wm for a new surface next time. return false; } catch (IllegalArgumentException e) { - Log.e(TAG, "IllegalArgumentException locking surface", e); + Log.e(TAG, "Could not lock surface", e); // Don't assume this is due to out of memory, it could be // something else, and if it is something else then we could // kill stuff (or ourself) for no reason. @@ -2343,7 +2343,14 @@ public final class ViewRootImpl implements ViewParent, unlockCanvasAndPostStartTime = System.nanoTime(); } - surface.unlockCanvasAndPost(canvas); + try { + surface.unlockCanvasAndPost(canvas); + } catch (IllegalArgumentException e) { + Log.e(TAG, "Could not unlock surface", e); + mLayoutRequested = true; // ask wm for a new surface next time. + //noinspection ReturnInsideFinallyBlock + return false; + } if (ViewDebug.DEBUG_LATENCY) { long now = System.nanoTime();