[Canvaskit] How to speed up "non trivial blending" in CPU canvas?

134 views
Skip to first unread message

Marcus Stenbeck

unread,
Mar 14, 2021, 9:59:04 AM3/14/21
to skia-discuss
I've been rendering video with Skottie, and I'm noticing that if there's transparency or some blending mode turned on my render FPS goes from ~60fps down to ~4fps. I've tried to triage what it could be, and it looks like there's a concept of "non-trivial blending" that I'm enabling by using blending or opacity.

Since I'm not in a web browser everything falls back to the CPU-based raster renderer which as expected doesn't have as good performance as the WebGL-backend one.

However, I saw that there's a render flag that's not exposed via CanvasKit. Would that speed up the rendering, and if so, could we expose this via the JavaScript API?

CanvasKit: https://github.com/google/skia/blob/master/modules/canvaskit/skottie_bindings.cpp#L177

Any other suggestions on what I could try to improve render speeds?

I haven't yet gotten to the point of building the CanvasKit wasm on my own to try this out, and I'm hoping to avoid learning the whole process of building myself if I can avoid it.


Marcus Stenbeck

unread,
Mar 14, 2021, 10:21:49 AM3/14/21
to skia-d...@googlegroups.com
Here's a fiddle with an example of a slow animation: https://jsfiddle.skia.org/canvaskit/be956f5c6a7aa8909bc50d5956b35da5eb3bd3979f9a09c72c399d1e8f8c242c

The image layer has a multiply blending mode (the "bm: 1" in the JSON). Toggle that prop between value 0 and 1 and you should be able to see the performance hit when using the CPU renderer.

--
You received this message because you are subscribed to a topic in the Google Groups "skia-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/skia-discuss/s0Y6ar8lGJA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/ddad7584-1992-4e6e-82fb-a1c76cf76b43n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages