question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance: interactivity is slow if Visual.Render() is overridden

See original GitHub issue

Bug Description: When display a huge amount of points, ScottPlot is lagging a lot, especially when you’re trying to move in the graph

Reproducing:

AvaPlot plot = this.FindControl<AvaPlot>("Plot");
var random = new Random();
plot.Plot.AddScatter(
    xs: Enumerable.Range(0, 10000).Select(x => (double)x).ToArray(),
    ys: Enumerable.Range(0, 10000).Select(x => (double)random.Next()).ToArray()
);

System Information

  • ScottPlot Version: 4.1.16
  • Operating System: Windows 11 / Ubuntu 20.04
  • Application Type: Avalonia

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bclehmanncommented, Jul 28, 2021

I am unfamiliar with your overriding of Visual.Render(DrawingContext context) in MainWindow.axaml.cs. I wonder if Visual.Render is called everytime that the control needs to be redrawn. This is bad, because you’re initializing a lot of data in this function.

I would move all of it to the constructor, or another function guaranteed to be called only once on startup.

0reactions
swhardencommented, Aug 4, 2021

Also I’m a little confused about an AvaPlot being used in a Windows WPF project. I would have expected to see a WpfPlot 🤔

I don’t have much Avalonia experience though. Is this a mistake, or is there some cross-platform fanciness going on here?

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Avalonia" Version="0.10.6" />
    <PackageReference Include="Avalonia.Desktop" Version="0.10.6" />
    <PackageReference Include="Avalonia.Diagnostics" Version="0.10.6" />
    <PackageReference Include="ScottPlot.Avalonia" Version="4.1.16" />
   </ItemGroup>
</Project>

EDIT: I was mistaken. This isn’t a WPF project, and the original issue says this is an Avalonia project. The WinExe line threw me off. My bad!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slow rendering | App quality
If your app suffers from slow UI rendering, then the system is forced to skip frames and the user perceives stuttering in your...
Read more >
Terrible performance of custom-drawn control
I found this question first, which become normal render-based graph (use InvalidateVisuals() to redraw). protected override void OnRender( ...
Read more >
CSS performance optimization - Learn web development | MDN
This article walks you through key CSS performance optimization ... and it is easy to override styles when needed later on if the...
Read more >
Baseline performance of rendering components is "slow"
Basically the issue I've run into is that it takes around 0.3-1.5 ms to render a component. In this case just a component...
Read more >
Performance features reference - Chrome Developers
A reference on all the ways to record and analyze performance in Chrome DevTools.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found