Skip to content

Commit 0239776

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Document MountItemDispatcher (#41114)
Summary: Pull Request resolved: #41114 changelog: [internal] MountItemDispatcher integrates with FabricUIManager in a non-obvious ways. This diff documents some of that. Reviewed By: NickGerleman Differential Revision: D50494929 fbshipit-source-id: ed3c1748765ca4590035be20f045ecfb14af86c2
1 parent e651a56 commit 0239776

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,11 @@ public void doFrameGuarded(long frameTimeNanos) {
12941294
}
12951295

12961296
try {
1297+
// First, execute as many pre mount items as we can within frameTimeNanos time.
1298+
// If not all pre mount items were executed, following may happen:
1299+
// 1. In case there are view commands or mount items in MountItemDispatcher: execute
1300+
// remaining pre mount items.
1301+
// 2. In case there are no view commands or mount items, wait until next frame.
12971302
mMountItemDispatcher.dispatchPreMountItems(frameTimeNanos);
12981303
mMountItemDispatcher.tryDispatchMountItems();
12991304
} catch (Exception ex) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,17 @@ public void dispatchMountItems(Queue<MountItem> mountItems) {
161161
}
162162
}
163163

164+
/*
165+
* Executes view commands, pre mount items and mount items in the respective order:
166+
* 1. View commands.
167+
* 2. Pre mount items.
168+
* 3. Regular mount items.
169+
*
170+
* Does nothing if `viewCommandMountItemsToDispatch` and `mountItemsToDispatch` are empty.
171+
* Nothing should call this directly except for `tryDispatchMountItems`.
172+
*/
164173
@UiThread
165174
@ThreadConfined(UI)
166-
/** Nothing should call this directly except for `tryDispatchMountItems`. */
167175
private boolean dispatchMountItems() {
168176
if (mReDispatchCounter == 0) {
169177
mBatchedExecutionTime = 0;
@@ -296,6 +304,12 @@ private boolean dispatchMountItems() {
296304
return true;
297305
}
298306

307+
/*
308+
* Executes pre mount items. Pre mount items are operations that can be executed before the mount items come. For example view preallocation.
309+
* This is a performance optimisation to do as much work ahead of time as possible.
310+
*
311+
* `tryDispatchMountItems` will also execute pre mount items, but only if there are mount items to be executed.
312+
*/
299313
@UiThread
300314
@ThreadConfined(UI)
301315
public void dispatchPreMountItems(long frameTimeNanos) {

0 commit comments

Comments
 (0)