Two GLCanvas fighting for resources...

Now that I’ve resolved by system stability issues I’ve been able to test my game a bit better and I’ve noticed another problem…

I have two GLCanvas on screen at once and it seems that they are fighting for resources!

First both canvas are running around 20fps, then one will jump to 60fps (monitor refresh rate) and the other will be starved of thread running time and only update maybe .3fps. This isn’t consistent and the two will occasionally switch roles.

Also I’ve noticed around every 5 minutes there is a reshape being triggered. But I think this is a seperate issue.

My log file is below, maybe its more clear from that… one panel is called ‘main’ and the other ‘selected’

Cheers

Peter

JOGL nightly build from 2006-04-06
W2K Sp4
java version “1.5.0_06”
Java™ 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot™ Client VM (build 1.5.0_06-b05, mixed mode)


[Debug]Selected Rendered 285 frames in 5.0 seconds = 57.0 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 301 frames in 5.0 seconds = 60.2 FPS
[Debug]Selected Rendered 297 frames in 5.0 seconds = 59.4 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Main Rendered 4 frames in 34.875 seconds = 0.11469534050179211 FPS
[Debug]Selected Rendered 300 frames in 5.016 seconds = 59.80861244019139 FPS
[Debug]Main Rendered 91 frames in 5.0 seconds = 18.2 FPS
[Debug]Main Rendered 196 frames in 5.0 seconds = 39.2 FPS
[Debug]Main Rendered 198 frames in 5.015 seconds = 39.48155533399801 FPS
[Debug]Main Rendered 225 frames in 5.0 seconds = 45.0 FPS
[Debug][RESHAPE] (0,0) (1118,895)
[Debug][RESHAPE] Done
[Debug]Main Rendered 213 frames in 5.0 seconds = 42.6 FPS
[Debug]Main Rendered 267 frames in 5.0 seconds = 53.4 FPS
[Debug]Main Rendered 284 frames in 5.0 seconds = 56.8 FPS
[Debug]Main Rendered 244 frames in 5.0 seconds = 48.8 FPS
[Debug]Selected Rendered 165 frames in 41.718 seconds = 3.955127283187113 FPS
[Debug]Selected Rendered 300 frames in 5.016 seconds = 59.80861244019139 FPS
[Debug]Selected Rendered 301 frames in 5.0 seconds = 60.2 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 282 frames in 5.0 seconds = 56.4 FPS
[Debug]Main Rendered 69 frames in 36.172 seconds = 1.9075528032732503 FPS
[Debug]Selected Rendered 267 frames in 8.047 seconds = 33.18006710575369 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug][RESHAPE] (0,0) (1118,895)
[Debug][RESHAPE] Done
[Debug]Main Rendered 153 frames in 11.047 seconds = 13.849914003801937 FPS
[Debug]Selected Rendered 299 frames in 5.0 seconds = 59.8 FPS
[Debug]Selected Rendered 300 frames in 5.0 seconds = 60.0 FPS
[Debug]Selected Rendered 301 frames in 5.016 seconds = 60.00797448165869 FPS

Do you have a test case?

How many threads do you have running causing these canvases to repaint themselves? Ideally you should have only one “animation” thread forcing the canvases to redraw. Note that the Animator class in com.sun.opengl.util has the option of animating more than one GLDrawable.

Hi Ken,

Ah ha, you are right and that makes sense, I currently have quite seperate graphical components on screen at the same time, but each with it’s own Animator.

So do I need to have a global Animator for all canvases that I pass to every component? that is going to make the code quite messy I think… or do you think I’d be better to wrap the Animator into a singleton? btw can it be started without any canvas initially with no problems? I see an empty constructor.
Also I have a third panel with a GLCanvas and a seperate Animator that I stop() after a single frame. So if I only have a single Animator for the game then I guess I could just return immediately from display() method when the anim is paused in that case.

Thanks for your help again :slight_smile:

Peter

Seems to work with a single new Animator() and then passing this instance to the other components and adding the canvases later :slight_smile:

Thanks.