Hint: Multiple wxGLCanvas Performance Degradation Linux

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi Folks,

Following issue with wxWidgets 2.8.12 under Linux Mint - Cinnamon Desktop.

Two wxGLCanvas on two different wxFrame, sharing the same wxGLRenderContext, renderloop with wxTimer, Interval 10ms, VSync disabled, SwapBuffers for each wxGLCanvas each iteration.

If the program runs longer than 1.5 hours, the performance degrades and sooner or later it seems that the Linux Desktop hangs.
After a while the program terminates with:

Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

I was able to resolve this, only be re-creating the wxGLCanvas(es)/wxGLRenderContext periodically.

Hope this helps someone out there.

If someone has a better solution or a hint what's causing this, that would be greatly appreciated.

Cheers!

Stex
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by Manolo »

It seems that the GPU memory is not fully cleaned. Some minor leak is accumulating until GPU memory is full.
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Many thanks Manolo,

Are there any specific opengl/wxGLCanvas/wxGLContext function one can use to clear the GPU memory?
I've searched the web a lot but could'nt find anything useful.

Many thanks!

Stex
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by Manolo »

wxGLCanvas and wxGLContext are very simple classes to create and handle an OGL context. No more.
It's possible that each vendor (ATI, NVIDIA, etc) implementation clears the GPU memory at context deletion. I don't know.

You can use an "OpenGL debugger" to find some errors, leaks, etc.
http://www.opengl.org/wiki/Debugging_Tools
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by doublemax »

Theoretically it could be a bug in wxWidgets, but if you opened a bug report, you would be asked for two things:

a) test it with the latest wxWidgets version 3.0.1 or the current development version and check if the problem still occurs

b) a minimal compilable sample that shows the problem
Use the source, Luke!
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi,

Many thanks for the replies.

@doublemax: personally I don't think that this is a wxWidgets bug. I've built a minimal sample yesterday, currently its running on the test machine. If the Issue happens, I'll upload the sample here.

Cheers

Stex
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi,

So - with the minimal sample I've built, the issue I described also happens, though it needs to run longer then 4 hours...
The problem manifests itself also earlier after 2h ca - when you try to quit the program, it takes up to one minute to complete.

The sample project is built with Code::Blocks IDE.

Please find ZIP Attached to the post.

Cheers

Stex
Attachments
WXOpenGLTest.zip
(373.07 KiB) Downloaded 105 times
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

BTW:
if you set the OuputCount in the sample to a high value, the crash happens earlier - a friend of mine tested it with 120 Outputs -> Crash after 15 minutes...

Edit:
Another hint: re-creating the wxGLContext only does'nt help - the wxGLCanvas needs to be re-created too...

Cheers

Stex
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by doublemax »

Can you test with wxWidgets 3.0.1? I know that several things regarding OpenGL context handling have changed there, it's possible that (knowingly or unknowingly) the bug was fixed.
Use the source, Luke!
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi doublemax,

I'll give the sample a try with wxWidgets 3.0.1 and post the outcome here asap.

Nevertheless, I fear to move the whole application to wxWidgets 3.0.1 only for this issue - too many variables to consider...

Many thanks,

Stex
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by Manolo »

WxWidgets has evolved regarding OGL context since 2.8. But the changes only afects how the OGL is created.
It's very likely that yor app will suffer the same error with the lastest wx-trunk.

Looking at your code I see yo set a gl-Depth-size. But you don't clear it in every loop.
Try changing glClear(GL_COLOR_BUFFER_BIT) with glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT).
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi Manolo,

Many thanks, I'll give it a try and post the outcome here.

Cheers

Stex
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi,
Unfortunately glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) does'nt solve the issue...

Cheers

Stex
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by Manolo »

In order to get more information when the app crashes, run it under a debugger (i.e. gdb).
You can use "bt" right after the crash to get the last path of execution.
stex
Earned a small fee
Earned a small fee
Posts: 15
Joined: Sun Sep 22, 2013 5:07 pm

Re: Hint: Multiple wxGLCanvas Performance Degradation Linux

Post by stex »

Hi Manolo,

I already use gdb, the problem is with this error if I want to backtrace I get "No Stack"...

e.g. In Linux Terminal, and the executable compiled with debugging symbols

ulimit -c unlimited
./WXOpenGLTest

then after the crash
gdb
backtrace

No Stack...
Post Reply