diff options
| author | Robert Carr <racarr@google.com> | 2021-05-05 17:36:47 -0700 |
|---|---|---|
| committer | Rob Carr <racarr@google.com> | 2021-05-07 18:53:00 +0000 |
| commit | e9ea91f47d14920a0a39f1d2cd6e63da7cc2b5d9 (patch) | |
| tree | 55773de61b4ee179e83d76181f90b8f1fd4da0b7 /core/java/android/view/ViewRootInsetsControllerHost.java | |
| parent | 0e4d7f142b781bb6721c574592ba62a062bad183 (diff) | |
SyncRtSurfaceTransactionApplier: Improve thread safety
If the calling thread releases the SurfaceControl passed
to SyncRtSurfaceTransactionApplier concurrently with the
applier preparing the transaction, this can lead to a
synchronization error and a crash. Once the state is
inside the transaction no further synchronization is required
as the native transaction will hold its own sp<SurfaceControl>
reference. By constructing the Transaction on the calling thread
and deferring application to the RenderThread we enable the calling
thread to not have any release synchronization requirements with
RenderThread.
Bug: 186391509
Change-Id: I585e1a9d3baf9ea384b00408b6253f34487d5037
Diffstat (limited to 'core/java/android/view/ViewRootInsetsControllerHost.java')
| -rw-r--r-- | core/java/android/view/ViewRootInsetsControllerHost.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootInsetsControllerHost.java b/core/java/android/view/ViewRootInsetsControllerHost.java index 514fb29029d0..d8cd6056de90 100644 --- a/core/java/android/view/ViewRootInsetsControllerHost.java +++ b/core/java/android/view/ViewRootInsetsControllerHost.java @@ -127,7 +127,9 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host { // Window doesn't support hardware acceleration, no synchronization for now. // TODO(b/149342281): use mViewRoot.mSurface.getNextFrameNumber() to sync on every // frame instead. - mApplier.applyParams(new SurfaceControl.Transaction(), -1 /* frame */, params); + final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); + mApplier.applyParams(t, params); + mApplier.applyTransaction(t, -1); } } |
