-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application Slows when GLControl Out of View #28
Comments
This seems odd, but I haven't done a lot with the GLControl and background threads. Your notes seem to suggest that maybe there's runaway window messaging going on. Does the CPU usage spike as well when the refresh rate or performance drops? Also, can you describe a little about what hardware you're running on? Which version of Windows (presumably this is Windows?), CPU, GPU, etc? |
I only notice an increase in CPU when opening up a child form while the GLControl is out of view. Normally it would take 1 core an additional 10% for a very short period, but when the issue is happening the 1 core goes up 10% for 5 seconds. |
I could probably make a demo project. Would that be helpful in this scenario? |
I found that the slowdown is associated with the NVIDIA GPU. When the application is set to use the INTEL GPU the issue goes away. Additionally, it happens equally when using the UI thread or a background thread for OpenTK drawing. Check out the demo project and video below. The video shows how the frame rate changes when switching between tabs (hiding the GLControl), first illustrating INTEL and second illustrating NVIDIA. I've tried changing between the NVIDIA Game Ready and Studio drivers (516.94) with the same result. I've also tried messing with other NVIDIA control panel settings (PhysX, etc) with the same result. If you have a NVIDIA GPU I'd be curios if you could reproduce this using the demo below. OpenTK.Graphics.Card.Demo.mp4 |
UPDATE: Tested on another computer with a NVIDIA RTX 2070 and the issue is not present. |
All of the delay happens in the swap buffers line. If I downloaded the OpenTK source is there anything that might be debuggable inside of the swap buffers method, or is this an unsolvable driver issue of some sort? |
Ouch. Sadly, no, SwapBuffers() forwards pretty directly through OpenTK and GLFW, and goes directly into the video driver. If you're experiencing slowdowns there, it's a driver issue and there's not much that can be done about it other than detecting when the panel is in a hidden tab and then not rendering. |
Definitely a weird issue. My recommendation/workaround is just to avoid submitting drawcalls for stuff that isn't going to appear on the screen. You can just avoid calling |
That's doable. The only other difference in API from the original is the ability to set Vsync. Probably not related, but is there a way to set this in OpenTK 4? |
OpenTK 4 |
I'll look into enabling VSync in GLControl for |
Setup:
Windows 10 Pro 21H2.
OpenGL 3.3 core running on a NVIDIA GeForce GTX 1050.
Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz CPU
WinForms NET 6
OpenTK 4.7.4
OpenTK.WinForms 4.0.0-pre-6
Issue:
When the parent form of the GLControl is minimized, or the GLControl is hidden from view on an unseen tab page of a tab control, the refresh rate of OpenGL drops from 2ms to ~33ms. Additionally, the entire application UI runs about 20x slower than normal. Completely unrelated child forms that normally open in ~250ms to open take ~5 seconds to open.
Notes:
This issue did not occur when using NET 4.8 with the original GLControl. The only obvious difference with the NET 4.8 GLControl version is that VSync was set to False (VSync property does not exist with new version).
The text was updated successfully, but these errors were encountered: