Oliver Kwast
I looked at the diff, but I’m not entirely sure I get it — why does this change improve the framerate so much?
1 3
Samuel
Reanimated is basically a babel plugin that converts your code to multi-threaded concurrent JS. This means that when you have a worklet, it has to serialise the closure to the UI thread which can be really slow when you’re closing over more than you realise. Although in this case I think it’s a bug
1 10
Krzysztof Magiera
This doesn't have to do anything to do with serialization. Worklets are only "serialized" when created, so in this instance only when headerMode changes, which I assume isn't frequent. Serialization only happens once for a given object and then it is cached, so withSpring is only serialized once
1 6
Krzysztof Magiera
What this change does it is simply skips calling `withSpring(0, {})` in favor of executing it only once when mutable is created and caching that value. withSpring returns an animation object which gets cached in a mutable in this case.
1 6
Krzysztof Magiera
You should be able to verify that by leaving reference to withSpring inside that worklet but just not calling it. In that case this should not degrade performance. I believe it is simply the runtime cost of withSpring call that needs to be optimized
2 10