Skia rendering performance for a 2d drawing app

164 views
Skip to first unread message

Rob Christenson

unread,
Jan 10, 2023, 7:18:21 PM1/10/23
to skia-discuss
Hey folks,

I'm working on a 2d drawing app (think scrollable canvas where users can draw various paths/shapes/objects) and came across skia as a potential for the rendering system. 

I spun up a quick test app (using a dev debug built skia) on mac using metal where I created an SkSurface and associated SkCanvas from an MTKView. To get a sense of performance, I set up a basic loop inside of my drawInMTKView delegate to render 5000 rects into the gpu backed SkCanvas. When doing this, the app seems to be rendering around 10 frames per second, with CPU usage pegged to 100%. Profiling the cpu usage has 83% of the cpu time being taken during the SkCanvas::onDrawRect call, slowly decreasing as the call stack goes down into the skgpu::SurfaceDrawContext::addDrawOp call. (So most of the time is taken in SkCanvas::onDrawRect, skgpu::SurfaceDrawContext::drawRect ... fillRectToRect ... drawFilledQuad)

The idea here was to move to skia rendering, so when a user moves the app canvas or moves an object the frame redraw would be handled by the GPU, instead of being bound by CPU based 2d drawing like I currently am using quartz as my drawing framework. 

I also ran a test where I was thinking each object could be redrawn into an SkImage using a raster surface as required with a cached image for each object being composited during each draw call into the gpu backed surface, but even then compositing all the cached images into the gpu backed SkCanvas was giving poor performance once I was at 1000 or so.

Does anyone have any thoughts as to if I'm missing something with my config here, totally misunderstood what I could hope to achieve with skia, or thoughts as to different approaches I could take to improve rendering performance?

Thanks for any help



Brian Osman

unread,
Jan 10, 2023, 7:22:44 PM1/10/23
to skia-d...@googlegroups.com
You mentioned you're using a debug build - have you tried the timing with a release build? Skia should be capable of that workload pretty easily, but we do some pretty extensive (and expensive) extra work in debug builds, to verify correctness. The performance delta between debug and release can be pretty severe.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/e648f8aa-0b88-4db2-8b94-45ecbad8d4fbn%40googlegroups.com.

Rob Christenson

unread,
Jan 10, 2023, 8:11:09 PM1/10/23
to skia-d...@googlegroups.com
I definitely did not try profiling with a release build yet. I probably should have before posting, but I was stuck thinking I made a mistake on my fundamental approach here. With the reassurance that skia should be able to handle that workload I'll try building skia for release and taking some performance metrics and report back if things seem off still. Thanks for the quick suggestion. 

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/Gu96hO4UB48/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/CAMcBjo59A3weJAH69TaeuYXU3D0yJdmGn8ZMcEhxU4yOMy%3DGhA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages