@@ -21,7 +21,6 @@ import com.facebook.react.fabric.FabricUIManager
2121import com.facebook.react.fabric.mounting.mountitems.DispatchCommandMountItem
2222import com.facebook.react.fabric.mounting.mountitems.MountItem
2323import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
24- import com.facebook.react.internal.tracing.PerformanceTracer
2524import com.facebook.systrace.Systrace
2625import java.util.Queue
2726import java.util.concurrent.ConcurrentLinkedQueue
@@ -202,16 +201,9 @@ internal class MountItemDispatcher(
202201 " MountItemDispatcher::mountViews viewCommandMountItems" ,
203202 )
204203
205- PerformanceTracer .trace(
206- " view commands" ,
207- " Renderer" ,
208- " ⚛ Native" ,
209- { ->
210- for (command in commands) {
211- dispatchViewCommand(command)
212- }
213- },
214- )
204+ for (command in commands) {
205+ dispatchViewCommand(command)
206+ }
215207
216208 Systrace .endSection(Systrace .TRACE_TAG_REACT )
217209 }
@@ -223,21 +215,12 @@ internal class MountItemDispatcher(
223215 Systrace .TRACE_TAG_REACT ,
224216 " MountItemDispatcher::mountViews preMountItems" ,
225217 )
226-
227- PerformanceTracer .trace(
228- " premount" ,
229- " Renderer" ,
230- " ⚛ Native" ,
231- { ->
232- for (preMountItem in preMountItems) {
233- if (ReactNativeFeatureFlags .enableFabricLogs()) {
234- printMountItem(preMountItem, " dispatchMountItems: Executing preMountItem" )
235- }
236- executeOrEnqueue(preMountItem)
237- }
238- },
239- )
240-
218+ for (preMountItem in preMountItems) {
219+ if (ReactNativeFeatureFlags .enableFabricLogs()) {
220+ printMountItem(preMountItem, " dispatchMountItems: Executing preMountItem" )
221+ }
222+ executeOrEnqueue(preMountItem)
223+ }
241224 Systrace .endSection(Systrace .TRACE_TAG_REACT )
242225 }
243226
@@ -246,56 +229,44 @@ internal class MountItemDispatcher(
246229 Systrace .TRACE_TAG_REACT ,
247230 " MountItemDispatcher::mountViews mountItems to execute" ,
248231 )
232+ val batchedExecutionStartTime = SystemClock .uptimeMillis()
233+
234+ for (mountItem in items) {
235+ if (ReactNativeFeatureFlags .enableFabricLogs()) {
236+ printMountItem(mountItem, " dispatchMountItems: Executing mountItem" )
237+ }
238+
239+ val command = mountItem as ? DispatchCommandMountItem
240+ if (command != null ) {
241+ dispatchViewCommand(command)
242+ continue
243+ }
249244
250- PerformanceTracer .trace(
251- " mount" ,
252- " Renderer" ,
253- " ⚛ Native" ,
254- { ->
255- val batchedExecutionStartTime = SystemClock .uptimeMillis()
256-
257- for (mountItem in items) {
258- if (ReactNativeFeatureFlags .enableFabricLogs()) {
259- printMountItem(mountItem, " dispatchMountItems: Executing mountItem" )
260- }
261-
262- val command = mountItem as ? DispatchCommandMountItem
263- if (command != null ) {
264- dispatchViewCommand(command)
265- continue
266- }
267-
268- try {
269- executeOrEnqueue(mountItem)
270- } catch (e: Throwable ) {
271- // If there's an exception, we want to log diagnostics in prod and rethrow.
272- FLog .e(TAG , " dispatchMountItems: caught exception, displaying mount state" , e)
273- for (m in items) {
274- if (m == = mountItem) {
275- // We want to mark the mount item that caused exception
276- FLog .e(
277- TAG ,
278- " dispatchMountItems: mountItem: next mountItem triggered exception!" ,
279- )
280- }
281- printMountItem(m, " dispatchMountItems: mountItem" )
282- }
283-
284- if (mountItem.getSurfaceId() != View .NO_ID ) {
285- mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
286- }
287-
288- if (ReactIgnorableMountingException .isIgnorable(e)) {
289- ReactSoftExceptionLogger .logSoftException(TAG , e)
290- } else {
291- throw e
292- }
293- }
245+ try {
246+ executeOrEnqueue(mountItem)
247+ } catch (e: Throwable ) {
248+ // If there's an exception, we want to log diagnostics in prod and rethrow.
249+ FLog .e(TAG , " dispatchMountItems: caught exception, displaying mount state" , e)
250+ for (m in items) {
251+ if (m == = mountItem) {
252+ // We want to mark the mount item that caused exception
253+ FLog .e(TAG , " dispatchMountItems: mountItem: next mountItem triggered exception!" )
294254 }
295- batchedExecutionTime + = SystemClock .uptimeMillis() - batchedExecutionStartTime
296- },
297- )
255+ printMountItem(m, " dispatchMountItems: mountItem" )
256+ }
257+
258+ if (mountItem.getSurfaceId() != View .NO_ID ) {
259+ mountingManager.getSurfaceManager(mountItem.getSurfaceId())?.printSurfaceState()
260+ }
298261
262+ if (ReactIgnorableMountingException .isIgnorable(e)) {
263+ ReactSoftExceptionLogger .logSoftException(TAG , e)
264+ } else {
265+ throw e
266+ }
267+ }
268+ }
269+ batchedExecutionTime + = SystemClock .uptimeMillis() - batchedExecutionStartTime
299270 Systrace .endSection(Systrace .TRACE_TAG_REACT )
300271 }
301272
@@ -326,34 +297,26 @@ internal class MountItemDispatcher(
326297 private fun dispatchPreMountItemsImpl (deadline : Long ) {
327298 Systrace .beginSection(Systrace .TRACE_TAG_REACT , " MountItemDispatcher::premountViews" )
328299
329- PerformanceTracer .trace(
330- " premount" ,
331- " Renderer" ,
332- " ⚛ Native" ,
333- { ->
334- // dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems
335- // from
336- // reentering during dispatchPreMountItems
337- inDispatch = true
338-
339- try {
340- while (true ) {
341- if (System .nanoTime() > deadline) {
342- break
343- }
344-
345- // If list is empty, `poll` will return null, or var will never be set
346- val preMountItemToDispatch = preMountItems.poll() ? : break
347- if (ReactNativeFeatureFlags .enableFabricLogs()) {
348- printMountItem(preMountItemToDispatch, " dispatchPreMountItems" )
349- }
350- executeOrEnqueue(preMountItemToDispatch)
351- }
352- } finally {
353- inDispatch = false
354- }
355- },
356- )
300+ // dispatchPreMountItems cannot be reentrant, but we want to prevent dispatchMountItems from
301+ // reentering during dispatchPreMountItems
302+ inDispatch = true
303+
304+ try {
305+ while (true ) {
306+ if (System .nanoTime() > deadline) {
307+ break
308+ }
309+
310+ // If list is empty, `poll` will return null, or var will never be set
311+ val preMountItemToDispatch = preMountItems.poll() ? : break
312+ if (ReactNativeFeatureFlags .enableFabricLogs()) {
313+ printMountItem(preMountItemToDispatch, " dispatchPreMountItems" )
314+ }
315+ executeOrEnqueue(preMountItemToDispatch)
316+ }
317+ } finally {
318+ inDispatch = false
319+ }
357320
358321 Systrace .endSection(Systrace .TRACE_TAG_REACT )
359322 }
0 commit comments