Fix a crash caused by transaction

A native transaction passed from webview is sent back to native side, so java side does not manage the life cycle of the transaction.

Bug: 191414767
Test: Play a video, switch to another app, wait for 10 seconds
Change-Id: I013052c202b445438d6cb6497f5f9a2fc22a2b85
This commit is contained in:
Huihong Luo
2021-06-24 10:04:32 -07:00
parent ef1bb2c9fa
commit 4df4151bc0
9 changed files with 29 additions and 26 deletions

View File

@@ -2610,16 +2610,6 @@ public final class SurfaceControl implements Parcelable {
= sRegistry.registerNativeAllocation(this, mNativeObject);
}
/**
* Create a transaction object that wraps a native peer.
* @hide
*/
Transaction(long nativeObject) {
mNativeObject = nativeObject;
mFreeNativeResources =
sRegistry.registerNativeAllocation(this, mNativeObject);
}
private Transaction(Parcel in) {
readFromParcel(in);
}

View File

@@ -1371,8 +1371,12 @@ public final class ViewRootImpl implements ViewParent,
HardwareRenderer.ASurfaceTransactionCallback callback = (nativeTransactionObj,
nativeSurfaceControlObj,
frameNr) -> {
Transaction t = new Transaction(nativeTransactionObj);
mergeWithNextTransaction(t, frameNr);
if (mBlastBufferQueue == null) {
return false;
} else {
mBlastBufferQueue.mergeWithNextTransaction(nativeTransactionObj, frameNr);
return true;
}
};
mAttachInfo.mThreadedRenderer.setASurfaceTransactionCallback(callback);
}