Replies: 2 comments
-
I'd like to mention the provided particles video is the current implementation that I mentioned with optimizations applied. |
Beta Was this translation helpful? Give feedback.
-
This is very cool, based on the demo you shared, I expect you to get very descent performance even on low-end device using one component per confetti and each confetti is using https://shopify.github.io/react-native-skia/docs/animations/hooks#usepathvalue. Now we're exposing a new API that would allow you to do all of this in a single draw call: #2134 but you won't see performance improvements there. We only identified this new API to be faster in an handful of use-cases. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently making a
ConfettiPopper
component which spawns a variable amount ofConfettiPiece
child componentsThe purpose of such a component is to create a confetti/snow type of animation where various "particles" are spawned in and rain from the top. Something similar to party.js (but a little different.)
Right now I'm able to get decent performance (60 fps compiled for release with low thermals on the app) using the following strategies:
ConfettiPopper
is responsible for spawningConfettiPiece
useFrameCallback
for custom animation logicSkia.Path.Make()
SharedValue
path andpath.rewind()
to minimize allocationsIt seems that the task can be broken down into the following steps:
To me it seems that the order of how taxing each step is from a performance perspective is as follows:
3 -> 2 -> 1 (ordered from most exhausting to least exhausting.)
My current code looks like the following:
I want to point out that I tried many different strategies, however the best performance in both debug and release was achieved by the above solution.
Some other ideas I tried:
Offset
component (performed pretty poorly and its not really flexible)transform
prop (poor performance from my testing but not really sure why)Skia.Path.MakeFromSVG()
and transforming them usingpath.transfrom
usePathValue
and without,usePathValue
performed disappointingly poorly.Most of the aforementioned ideas struggled to maintain 60fps in Debug, and while maintaining 60fps in Release, would heat up my phone a lot.
So I'm left wondering two things:
path.transform
with a cached path representation?Beta Was this translation helpful? Give feedback.
All reactions