Fixed a few issues with blast sync with SurfaceView
If SurfaceView changed and needs to update its SurfaceControl, it will append its changes to the main window's blast sync transaction. This is to ensure it can synchronize with the main window. However, if SV changes, but the main window doesn't need to submit a new frame, the logic to synchronize doesn't work. This changes fixes a few issues 1. Make sure to force a full redraw when mNextDrawUseBLASTSyncTransaction. This is to ensure we get the proper callbacks even if there's no new content to draw 2. Clear nextTransaction in BBQ when a frameCompleteCallback is invoked. In most cases the transaction in BBQ is already cleared since the frameCompleteCallback is called after a frame is latched and BBQ will clear the nextTransaction that was set. This is needed when hwui won't draw a new frame since there's nothing new to draw. In that case, we will get an immediate frameCompleteCallback without invoking the processNextBuffer. If VRI doesn't clear the transaction, BBQ will try to use the stale transaction when a new frame does come in Test: blast sync in SV enabled doesn't freeze YT Bug: 172579592 Change-Id: Idca7accdf094dbb4585897e4e884c1147b1a2cd0
This commit is contained in:
@@ -3912,7 +3912,8 @@ public final class ViewRootImpl implements ViewParent,
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean fullRedrawNeeded = mFullRedrawNeeded || mReportNextDraw;
|
||||
final boolean fullRedrawNeeded =
|
||||
mFullRedrawNeeded || mReportNextDraw || mNextDrawUseBLASTSyncTransaction;
|
||||
mFullRedrawNeeded = false;
|
||||
|
||||
mIsDrawing = true;
|
||||
@@ -9921,6 +9922,18 @@ public final class ViewRootImpl implements ViewParent,
|
||||
} else {
|
||||
t.merge(mRtBLASTSyncTransaction);
|
||||
}
|
||||
|
||||
// There's potential for the frame callback to get called even if nothing was drawn.
|
||||
// When that occurs, we remove the transaction sent to BBQ since the draw we were
|
||||
// waiting on will not happen. We can apply the transaction here but it will not contain
|
||||
// a buffer since nothing new was drawn.
|
||||
//
|
||||
// This is mainly for the case when the SurfaceView has changed and wants to synchronize
|
||||
// with the main window. If the main window doesn't need to draw anything, we can just
|
||||
// apply the transaction without the new buffer from the main window.
|
||||
if (mBlastBufferQueue != null) {
|
||||
mBlastBufferQueue.setNextTransaction(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.graphics;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceControl;
|
||||
|
||||
@@ -60,8 +61,13 @@ public final class BLASTBufferQueue {
|
||||
return nativeGetSurface(mNativeObject, true /* includeSurfaceControlHandle */);
|
||||
}
|
||||
|
||||
public void setNextTransaction(SurfaceControl.Transaction t) {
|
||||
nativeSetNextTransaction(mNativeObject, t.mNativeObject);
|
||||
/**
|
||||
* Send the transaction to BBQ so the next frame can be added and not applied immediately.
|
||||
* This gives the caller a chance to apply the transaction when it's ready.
|
||||
* @param t The transaction to add the frame to. This can be null to clear the transaction.
|
||||
*/
|
||||
public void setNextTransaction(@Nullable SurfaceControl.Transaction t) {
|
||||
nativeSetNextTransaction(mNativeObject, t == null ? 0 : t.mNativeObject);
|
||||
}
|
||||
|
||||
public void update(SurfaceControl sc, int width, int height) {
|
||||
|
||||
Reference in New Issue
Block a user