From d821a9f2a094925e4bb68b020680cb9c66f22611 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Fri, 5 Jun 2020 17:09:04 -0700 Subject: [PATCH] Refactor how synchronous updates are queued and executed in FabricUIManager Summary: As a simple refactor, I want to 1) have `synchronouslyUpdateViewOnUIThread` only catch exceptions for the specific MountItem being synchronously executed, 2) not assume that scheduleMountItem will always cause synchronous execution. I think this makes the logic here a little more clear and it scopes how we swallow exceptions, which could be swallowing too many errors right now actually. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D21911804 fbshipit-source-id: 1b1a465cadd60c72c69b556469276c9ee6b2dfcc --- .../com/facebook/react/fabric/FabricUIManager.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index a556eb5fc24..07b6258db04 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -492,16 +492,21 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { @ThreadConfined(UI) public void synchronouslyUpdateViewOnUIThread(int reactTag, @NonNull ReadableMap props) { UiThreadUtil.assertOnUiThread(); - long time = SystemClock.uptimeMillis(); + int commitNumber = mCurrentSynchronousCommitNumber++; + + // We are on the UI thread so this is safe to call. We try to flush any existing + // mount instructions that are queued. + tryDispatchMountItems(); + try { ReactMarker.logFabricMarker( ReactMarkerConstants.FABRIC_UPDATE_UI_MAIN_THREAD_START, null, commitNumber); if (ENABLE_FABRIC_LOGS) { FLog.d(TAG, "SynchronouslyUpdateViewOnUIThread for tag %d", reactTag); } - scheduleMountItem( - updatePropsMountItem(reactTag, props), commitNumber, time, 0, 0, 0, 0, 0, 0); + + updatePropsMountItem(reactTag, props).execute(mMountingManager); } catch (Exception ex) { // TODO T42943890: Fix animations in Fabric and remove this try/catch ReactSoftException.logSoftException(