Commit 3a7c8ba
Refactor FrameTimingsObserver for multi-activity support (facebook#55740)
Summary:
Pull Request resolved: facebook#55740
Changelog: [internal]
Previously, `FrameTimingsObserver` required a `Window` at construction time and could not track frames across activity changes. In multi-activity Android apps, navigating between activities would cause frame timing to stop being recorded from the new activity's window.
This refactors `FrameTimingsObserver` to use a push-based setter pattern where `ReactHostImpl` calls `setCurrentWindow()` whenever the current activity changes (in `onHostResume` and `moveToHostDestroy`). The observer re-registers its frame metrics listener on the new window automatically.
Key changes:
- Remove `window` from constructor, add `setCurrentWindow()` method
- Add `isStarted` flag to track observer state for proper listener registration on window changes
- Mark `currentWindow` as `Volatile` for thread safety (UI thread writes, background coroutine reads)
- Extract `registerFrameMetricsListener()` / `unregisterFrameMetricsListener()` helpers to reduce duplication
Reviewed By: emily8rown
Differential Revision: D94358266
fbshipit-source-id: 21fcc237dda599088ef49d1427a45fb9cf449a521 parent 31c51a1 commit 3a7c8ba
File tree
2 files changed
+44
-18
lines changed- packages/react-native/ReactAndroid/src/main/java/com/facebook/react
- devsupport/inspector
- runtime
2 files changed
+44
-18
lines changedLines changed: 32 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
44 | 60 | | |
45 | 61 | | |
46 | 62 | | |
47 | 63 | | |
48 | 64 | | |
49 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
50 | 72 | | |
51 | 73 | | |
52 | 74 | | |
| |||
102 | 124 | | |
103 | 125 | | |
104 | 126 | | |
105 | | - | |
106 | | - | |
| 127 | + | |
107 | 128 | | |
108 | 129 | | |
109 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
110 | 134 | | |
111 | 135 | | |
112 | 136 | | |
113 | 137 | | |
114 | 138 | | |
115 | | - | |
| 139 | + | |
116 | 140 | | |
117 | 141 | | |
118 | 142 | | |
| |||
135 | 159 | | |
136 | 160 | | |
137 | 161 | | |
138 | | - | |
| 162 | + | |
139 | 163 | | |
140 | 164 | | |
141 | 165 | | |
142 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
143 | 169 | | |
144 | 170 | | |
145 | 171 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
| |||
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
| 855 | + | |
854 | 856 | | |
855 | 857 | | |
856 | 858 | | |
| |||
1571 | 1573 | | |
1572 | 1574 | | |
1573 | 1575 | | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1586 | 1586 | | |
1587 | 1587 | | |
1588 | 1588 | | |
| |||
0 commit comments