Skip to content

Commit

Permalink
Ignore exceptions when a Delete instruction is in the same BatchMount…
Browse files Browse the repository at this point in the history
…Item as its corresponding Create instruction during stopSurface

Summary:
See title. Basically during stopSurface a single BatchMountInstruction can contain both the Create and Delete MountItem for a single view, which will cause *only* the deletion to be executed.

There isn't really a way to prevent this and we're just trying to clean up as aggressively as possible, so we can safely ignore this.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D22779189

fbshipit-source-id: c44fd736835b04c5de776346ec3d34afa4860199
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Jul 27, 2020
1 parent 3bab643 commit 07722cf
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.fabric.mounting.mountitems;

import androidx.annotation.NonNull;
import com.facebook.common.logging.FLog;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
Expand All @@ -25,6 +26,7 @@
*/
@DoNotStrip
public class BatchMountItem implements MountItem {
static final String TAG = "FabricBatchMountItem";

private final int mRootTag;
@NonNull private final MountItem[] mMountItems;
Expand Down Expand Up @@ -77,13 +79,24 @@ public void execute(@NonNull MountingManager mountingManager) {
endMarkers();
}

/**
* In the case of teardown/stopSurface, we want to delete all views associated with a SurfaceID.
* It can be the case that a single BatchMountItem contains both the create *and* delete
* instruction for a view, so this needs to be failsafe.
*
* @param mountingManager
*/
public void executeDeletes(@NonNull MountingManager mountingManager) {
beginMarkers("deleteViews");

for (int mountItemIndex = 0; mountItemIndex < mSize; mountItemIndex++) {
MountItem mountItem = mMountItems[mountItemIndex];
if (mountItem instanceof RemoveDeleteMultiMountItem) {
((RemoveDeleteMultiMountItem) mountItem).executeDeletes(mountingManager, true);
try {
((RemoveDeleteMultiMountItem) mountItem).executeDeletes(mountingManager, true);
} catch (RuntimeException e) {
FLog.e(TAG, "Ignoring deletion exception", e);
}
}
}

Expand Down

0 comments on commit 07722cf

Please sign in to comment.