-
I found that if I add a node to a scrollview, the layout procedure is 10x slower. And I add logs to After diving into yoga for a very long time, I found the root cause may because of layout caching missing. The interesting part is that when scrollview's layout changes, the shadow node do re-calculate the cache, but the cache is saved inside the particular node, and this node will be dropped when next Is this a known issue? Anyone else noticed that scrollview hurts the performance? (I post here because I don't know whether this is a bug of yoga or a bug of RN). |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I wrote a JS demo in my fork, just use |
Beta Was this translation helpful? Give feedback.
-
I just test the behavior when fabric is disabled, and I found that when I touch an item, the |
Beta Was this translation helpful? Give feedback.
-
My colleague wrote me a better demo in the branch I pasted, now, to illustrate the problem, press the "This is a very useful comment about the code." item, then press the "ADD COMMENT", then press the newly added "This is a new comment.". According to my test, |
Beta Was this translation helpful? Give feedback.
-
@psionic12 this is a great analysis, thank you! Btw, we just analysed performance of the New Architecture and published the findings #123. I think some of it may be relevant to what you observed here, especially the missing
This is expected. In Fabric, when ScrollView scrolls, it needs to update its content offset. This triggers Fabric's state update, not to be confused with React's I hope this clarifies why layout pass is triggered more often in Fabric.
This sounds like a legit bug that is worth investigating. However, there is a special case: Text, or any shadow node with custom measure function. Their yoga node is dirtied every time they are cloned, forcing another measure pass. We use TextLayoutManager's cache here to make it fast. There are other options worth exploring. Cache is needed but Fabric could be smarted about how when it dirties yoga node. |
Beta Was this translation helpful? Give feedback.
@psionic12 this is a great analysis, thank you! Btw, we just analysed performance of the New Architecture and published the findings #123. I think some of it may be relevant to what you observed here, especially the missing
NDEBUG
compiler flag, which makes layout considerably slower.This is expected. In Fabric, when ScrollView scrolls, it needs to update its content offset. This triggers Fabric's state update, not to be confused with React's
useState
hook. Fabric's state update triggers layout pass. In ScrollView's case it should be mostly just getting cached values. State of user interface is repr…