diff options
author | Kan-Ru Chen <kanru@0xlab.org> | 2010-10-04 19:06:52 +0800 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2010-11-19 16:24:30 -0500 |
commit | 11a52b760154d75b98637e5802c1e0c683e2685b (patch) | |
tree | b0d27b9ebd3c6319082a03267f8a30a2fc1f84d9 | |
parent | 9c3709a1bdfdad1af4b16effeccf2a7dbd610d04 (diff) | |
download | frameworks_base-11a52b760154d75b98637e5802c1e0c683e2685b.zip frameworks_base-11a52b760154d75b98637e5802c1e0c683e2685b.tar.gz frameworks_base-11a52b760154d75b98637e5802c1e0c683e2685b.tar.bz2 |
frameworks: WindowManagerService: Fix out of memory for surface error
Surface.openTransaction and Surface.closeTransaction is not reentrant.
If we are updating the mouse surface when the WindowManager is also
updating the surfaces, the global transaction can be closed too early
by the other side. The results are random runtime exceptions and
unstable surface state.
Move the mouse surface update logic to the big surfaces update
loop, together with the other surfaces update logic.
Change-Id: I38a4f264f8de59899c3ac0fdaf9d8cd520d41947
-rw-r--r-- | services/java/com/android/server/WindowManagerService.java | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index c603f20..3994c3b 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -6625,10 +6625,8 @@ public class WindowManagerService extends IWindowManager.Stub //Slog.i(TAG, "Read next event " + ev); dispatchPointer(ev, (MotionEvent)ev.event, 0, 0); if (mMouseDisplayed) { - Surface.openTransaction(); - mMouseSurface.hide(); - Surface.closeTransaction(); mMouseDisplayed = false; + requestAnimationLocked(0); } break; case RawInputEvent.CLASS_MOUSE: @@ -6636,30 +6634,12 @@ public class WindowManagerService extends IWindowManager.Stub int mcx = (int)mmev.getX(); int mcy = (int)mmev.getY(); - if (mMouseSurface != null && (mMlx != mcx || mMly != mcy)) { - Surface.openTransaction(); - if (DEBUG_INPUT) - Slog.i(TAG, "Open transaction for the mouse surface"); - WindowState top = - (WindowState)mWindows.get(mWindows.size() - 1); - try { - if (DEBUG_INPUT) - Slog.i(TAG, "Move surf, x: " + - Integer.toString(mcx) + " y:" - + Integer.toString(mcy)); - - mMouseSurface.setPosition(mcx, mcy); - mMouseSurface.setLayer(top.mAnimLayer + 1); - if (!mMouseDisplayed) { - mMouseSurface.show(); - mMouseDisplayed = true; - } - mMlx = mcx; - mMly = mcy; - } catch ( RuntimeException e) { - Slog.e(TAG, "Failure showing mouse surface",e); - } - Surface.closeTransaction(); + if (mMlx != mcx || mMly != mcy) { + mMlx = mcx; + mMly = mcy; + if (!mMouseDisplayed) + mMouseDisplayed = true; + requestAnimationLocked(0); } dispatchPointer(ev, (MotionEvent)ev.event, 0, 0); break; @@ -10737,6 +10717,27 @@ public class WindowManagerService extends IWindowManager.Stub mBlurShown = false; } + // FOURTH LOOP: Display Mouse + if (mMouseSurface != null) { + if (mMouseDisplayed) { + WindowState top = + (WindowState)mWindows.get(mWindows.size() - 1); + try { + if (DEBUG_INPUT) + Slog.i(TAG, "Move surf, x: " + + Integer.toString(mMlx) + " y:" + + Integer.toString(mMly)); + mMouseSurface.show(); + mMouseSurface.setPosition(mMlx, mMly); + mMouseSurface.setLayer(top.mAnimLayer + 1); + } catch (RuntimeException e) { + Slog.e(TAG, "Failure showing mouse surface", e); + } + } else { + mMouseSurface.hide(); + } + } + if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION"); } catch (RuntimeException e) { Slog.e(TAG, "Unhandled exception in Window Manager", e); |