Skip to content

FormsPlot: Fix stack overflow exceptions caused by mouse-move renders#1913

Merged
swharden merged 10 commits intomainfrom
1906
Jun 30, 2022
Merged

FormsPlot: Fix stack overflow exceptions caused by mouse-move renders#1913
swharden merged 10 commits intomainfrom
1906

Conversation

@swharden
Copy link
Member

@swharden swharden commented Jun 26, 2022

swharden added 5 commits June 26, 2022 18:16
visualizes issue described by #1906
large images throw stack overflow exceptions faster, even when skipIfCurrentlyRendering is used
Render() in controls will not execute if the stack frame count exceeds this value
Do not Render() if the stack exceeds this depth. Resolves #1906
@swharden swharden marked this pull request as ready for review June 26, 2022 22:59
@AbeniMatteo
Copy link
Contributor

Don't merge this PR, this is a workaround and not a fix.
Tomorrow i'll do some test.

@AbeniMatteo
Copy link
Contributor

This is the commit that introduced .DoEvents():
ff0f219 winforms control improve mouse responsiveness

This rabbit hole is pretty deep, this is where i'm at.

  • I'm testing with 10.000.000 points, not 100
  • Removed all .DoEvents()
  • skipIfCurrentlyRendering shouldn't be needed anymore (globally, not only for the tracker demo)
  • No more occasional white flickers
  • There is a very small loss of perf (fluidity) that i still need to investigate

I hope it helps.

@swharden
Copy link
Member Author

this is where i'm at

Here's the diff: main...AbeniMatteo:ScottPlot:ab-fix-doevents

  • Removed all .DoEvents()
  • skipIfCurrentlyRendering shouldn't be needed anymore

These are big wins! Using Control.Refresh() instead of Application.DoEvents() with Control.Invalidate() would be a great improvement if it's that easy.

This rabbit hole is pretty deep

This simple topic tends to explode in complexity every time I look into it... Thanks for your effort on this front! I look forward to seeing what you come up with

@AbeniMatteo
Copy link
Contributor

This is a small (in terms of lines) but pretty invasive change so i'll leave it up to you.

No changes since my last post, the stutter in both is caused by GC collections (flickers are only present now because of .Invalidate()).
I tested all the demos and didn't notice any problem.

Now:

T4UH3VmoF4.mp4

After:

ke41o3FK1j.mp4

@swharden swharden changed the title Fix stack overflow exceptions caused by mouse-move renders FormsPlot: Fix stack overflow exceptions caused by mouse-move renders Jun 30, 2022
@swharden
Copy link
Member Author

Thanks for your work on this @AbeniMatteo!

I copied your changes from main...AbeniMatteo:ScottPlot:ab-fix-doevents into this PR and am merging it now.

@swharden swharden merged commit dacd3a3 into main Jun 30, 2022
@swharden swharden deleted the 1906 branch June 30, 2022 01:44
@AbeniMatteo
Copy link
Contributor

private void OnBitmapUpdated(object sender, EventArgs e) { pictureBox1.Refresh(); pictureBox1.Invalidate(); }

I think you left .Invalidate() in.

swharden added a commit that referenced this pull request Jun 30, 2022
@swharden swharden mentioned this pull request Jun 30, 2022
@BrentLiuCL
Copy link

Is there a sure enough way to eliminate the stack overflow exception during Refresh() calls?

As far as I've tried, this issue is still present.

Is there anything I can do to reduce the refresh frequency with the default interactions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FormsPlot: Frequent MouseMove events overflow the stack

3 participants