Commit ef4e88d
Mark FPS listener in ScrollViews as final, avoid reset in initView
Summary:
`mFpsListener` is injected via `ReactHorizontalScrollView`'s constructor and should live for the lifetime of the view. However, it was declared as a mutable field and nulled in `initView()`, which is called both during construction and when the view is recycled in a virtualized list. After recycling, `isScrollPerfLoggingEnabled()` returned false because `mFpsListener` was null, silently disabling FPS performance tracking for the rest of that view instance's lifecycle.
The fix moves `mFpsListener` to a `final` field initialized in the constructor, and removes the `mFpsListener = null` assignment from `initView()`. Applied to `ReactScrollView`, `ReactHorizontalScrollView`, and `ReactNestedScrollView`.
This is a safe change because both view managers are instantiated with a single instance of FPS listener, so recycled view instances will always reference the same FPS listener instance.
Changelog:
[Android][Fixed] - Fix FPS performance listener being cleared on ScrollView recycle
Differential Revision: D1023597471 parent 4cbe675 commit ef4e88d
3 files changed
Lines changed: 4 additions & 5 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | | - | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | 180 | | |
182 | 181 | | |
183 | 182 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
121 | | - | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
0 commit comments