Skia Performance

Hey :)

I’m working on a patch where I’m looping through 32 instances of a small class, and each one draws a few Skia primitives. Every instance outputs a Skia layer made up of some simple circles—some with shaders and filters, and everything gets masked once. Each instance also has its own unique behavior using random functions and dampers.

Performance is great at first, but after a while the frame rate starts to dip, and the “Render” value in the Perfmeter shoots up. Kinda strange—it runs smoothly in the beginning, but gradually gets worse. Not sure if my laptop is just struggling, or if there’s something in the patch that’s slowly dragging things down.

Here’s the function that generates the output layer for each instance:


Any ideas on what could be causing the slowdown or how to improve performance? Would really appreciate any tips—thanks! :)

Can you share the patch or a simplified version that shows the same behaviour?

eyes_test.vl (225.3 KB)

Thanks so much for your reply! :)

I made a simplified version of the Skia part of the patch, and it’s definitely running a bit smoother than the original/ bigger version. But I’m still noticing that the longer I move the mouse in the render window, the worse the performance gets over time.

Not sure if there’s too much caching going on or if that’s just expected behavior… but it feels like it should be running a bit smoother than it is.

Any tips on how I could improve performance would be super appreciated :)


I found the problem!

Actually, @schlonzo reported the same problem in this post:

Turns out, removing the SetMaskFilter + Blur from the class makes everything run nice and smooth again ;) looks like using MaskFilters inside a ForEach causes some kind of memory leak.

But thank you @bjoern for jumping in and offering help!

1 Like

I guess you can see the memory leak with this construction:

2 Likes

You could try putting everything that is not animated on Create and / or feed everything that is shared between instances from outside the loop.

2 Likes

Will try both - thank you ;)