-
Notifications
You must be signed in to change notification settings - Fork 981
Description
Hello,
I'm experiencing some problems with ScottPlot version 5 on linux, the rendering time is too big. If you enable the performance meter with double click, it shows 70-100 ms time and 10-15 fps on an empty plot. To run on linux I use an Avalonia gui, with custom-made control (this is not important, the root of the bug is plot.Render(SKSurface).
You may found a reproduction sample application on this repo.
I've looked at the code and conclude, that Extensions/SkiaSharpExtensions -> ApplyToPaint(this FontStyle fontStyle, SKPaint paint) is the root of the problem, and the exact call is SKTypeface.FromFamilyName(fontStyle.Name, skfs).
For some unknown reason this call takes about 4ms, and that function is called by axes measure and panel rendering 17 times each rendering time!
To test my assumptions, I've replaced the var assignment with
SKTypeface typeface = (_typeface == null) ? SKTypeface.FromFamilyName(fontStyle.Name, skfs) : _typeface;
and declared a static _typeface nearby at class level (private static SKTypeface? _typeface = null;). That is, I just cached the call's result. And, it began to work as expected! The frame rate became the same as I saw on Windows, 200+.
So, it seems some caching layer is needed to negate the slow call on Linux. I don't know the reasons, but I've checked that on two different distributions with the same outcome.
System Details
- ScottPlot Version: 5.0.1-beta
- Operating System: Ubuntu Linux 22.04.1 LTS, ArchLinux current
- Application Type: Avalonia (actually didn't matter)
- .NET Version: .NET 6.0, 7.0