Only retry ViewCommand mount items if exception is marked as "Retryable"

Summary:
Instead of just blindly retrying all ViewCommands if they fail - which could be dangerous, since it's arbitrary imperative commands we'd be executing twice, potentially with bad app state - we only retry if the ViewCommand throws a "RetryableMountingLayerException".

Changelog: [Internal] Optimization to ViewCommands

Reviewed By: mdvacca

Differential Revision: D20529985

fbshipit-source-id: 0217b43f4bf92442bcc7ca48c8ae2b9a9e543dc9
This commit is contained in:
Joshua Gross
2020-03-19 23:02:04 -07:00
committed by Facebook GitHub Bot
parent 7561adac77
commit 0fe548aa2a
5 changed files with 61 additions and 22 deletions
@@ -26,6 +26,7 @@ import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.RetryableMountingLayerException;
import com.facebook.react.bridge.SoftAssertions;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.config.ReactFeatureFlags;
@@ -762,7 +763,7 @@ public class NativeViewHierarchyManager {
UiThreadUtil.assertOnUiThread();
View view = mTagsToViews.get(reactTag);
if (view == null) {
throw new IllegalViewOperationException(
throw new RetryableMountingLayerException(
"Trying to send command to a non-existing view with tag ["
+ reactTag
+ "] and command "
@@ -777,7 +778,7 @@ public class NativeViewHierarchyManager {
UiThreadUtil.assertOnUiThread();
View view = mTagsToViews.get(reactTag);
if (view == null) {
throw new IllegalViewOperationException(
throw new RetryableMountingLayerException(
"Trying to send command to a non-existing view with tag ["
+ reactTag
+ "] and command "