Commit 01c9155
Fix debug build memory leak from fabric marker in updatePropsSynchronously (facebook#56561)
Summary:
## Changelog:
[Internal] [Fixed] - Fix debug build memory leak from fabric marker in updatePropsSynchronously
## Problem
`FabricUIManager.synchronouslyUpdateViewOnUIThread` logs `FABRIC_UPDATE_UI_MAIN_THREAD_START/END` fabric markers with a unique, ever-incrementing `commitNumber`. While `Fb4aReactFabricPerfLogger` consumed these markers correctly (via its `EventMetadata` pattern), `DevToolsReactPerfLogger` stored them in its `fabricCommitMarkers` map and only cleaned up entries on `FABRIC_BATCH_EXECUTION_END` — which is never emitted for synchronous updates. At 60fps with multiple animated views, ~300 orphaned `FabricCommitPoint` entries accumulated per second, causing unbounded memory growth.
## Why only UPDATE_UI_MAIN_THREAD is affected
All other fabric markers (COMMIT, DIFF, LAYOUT, FINISH_TRANSACTION, BATCH_EXECUTION) are emitted from the normal commit lifecycle in C++ → `IntBufferBatchMountItem`. They share the same `commitNumber` and always terminate with `BATCH_EXECUTION_END`, so they get cleaned up. `UPDATE_UI_MAIN_THREAD` is the only marker emitted from a separate path (`synchronouslyUpdateViewOnUIThread`) with its own `commitNumber` space (starting at 10000) and no `BATCH_EXECUTION_END`.
## Fix
`DevToolsReactPerfLogger` now also treats `FABRIC_UPDATE_UI_MAIN_THREAD_END` as a commit-end signal, triggering `onFabricCommitEnd` and cleanup of the `fabricCommitMarkers` entry. This is safe because `UPDATE_UI_MAIN_THREAD` markers are only emitted by `synchronouslyUpdateViewOnUIThread` (which never emits `BATCH_EXECUTION_END`), while normal commits use `BATCH_EXECUTION_END` (and never emit `UPDATE_UI_MAIN_THREAD`). No double-cleanup risk.
Reviewed By: cipolleschi
Differential Revision: D1018431471 parent 78190b4 commit 01c9155
1 file changed
Lines changed: 4 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
| |||
0 commit comments