"instanceHandle is null, event of type topSvgLayout will be dropped" logged repeatedly when SVG components are rapidly recycled in a FlatList
Description
While stress-testing a FlatList with aggressive cell recycling (small windowSize/initialNumToRender, large programmatic jumps via scrollToIndex) where each cell renders an SVG icon (<Svg>/<Path>), we noticed the following line printed repeatedly and rapidly in the Xcode console:
UIManagerBinding.cpp:135] instanceHandle is null, event of type topSvgLayout will be droppedWe're not certain of the exact internal cause, but observationally:
- It only appears when SVG components are being rapidly mounted/unmounted (e.g. via
FlatListrecycling with a very smallwindowSize). - It does not appear when scrolling manually at a normal pace - only when we force many mount/unmount cycles in quick succession (e.g. programmatically jumping between the first and last items of the list repeatedly).
- Setting
removeClippedSubviewson theFlatListappears to suppress the log entirely. - The event type reported is
topSvgLayout, which corresponds to this library's internalonSvgLayoutevent.
We're filing this as an observation in case it's useful signal for something worth investigating on this library's side, separate from how other libraries (e.g. react-native-reanimated) consume this event. We don't have a confirmed root cause for why onSvgLayout ends up being associated with a component whose instance handle is already gone - just a reliable set of conditions under which the log appears.
Steps to reproduce
- Render a list (e.g.
FlatList) where each item contains an SVG icon (e.g. a<Path>fromreact-native-svg). - Configure the list for aggressive cell recycling with a small viewport window, e.g.
windowSize={1},initialNumToRender={1},maxToRenderPerBatch={1}. - Programmatically jump the visible window between distant indices (e.g. call
scrollToIndexto jump from the first item straight to the last item, and back) repeatedly in a loop (e.g. every ~1000ms), instead of scrolling gradually. - Watch the native console (Xcode) while this runs.
- After a short time, the following line appears repeatedly:
UIManagerBinding.cpp:135] instanceHandle is null, event of type topSvgLayout will be dropped
Snack or a link to a repository
https://snack.expo.dev/@rca-mwhite/reanimated-svg-gettag-crash-repro
SVG version
15.15.5
React Native version
0.81.6
Platforms
iOS
JavaScript runtime
Hermes
Workflow
React Native
Architecture
Fabric (New Architecture)
Build type
None
Device
Real device
Device model
No response
Acknowledgements
Yes
Source: software-mansion/react-native-svg