draw() is not being called, but update() is... ?

Hello All,

I’m new to ofx, but not so much to C++.

I have some fairly heavy code doing openCV segmentation and clustering. All this code is in custom classes I’ve included in the ofx project. I’m using ofx v0071 linux64 on an ubuntu precise machine, ofxCv and lots of opencv::gpu calls.

I’m early in the implementation, so I’m not paying attention to performance yet. I’m now running about 3fps, as reported by ofGetLastFrameTime(), and the framerate is set to 1fps. I’m currently dumping the image buffer to disk to see what is going on using grabScreen().

Although update() continues to run, it seems at some point (it seems to happen at a different point each time I run, and I keep adding additional debugging code each time.) in execution draw() simply stops being called.

After a closer look at the output, it’s even worse, it seems at a later point in execution that draw() miraculously starts getting called again…

I’m not using too much RAM, but certainly using a lot of CPU usage, and perhaps a fair bit of GPU.

Are there cases when draw() is not longer called? For example when some limit has exceeded, like the time to render one frame? or for update() to return?

Any hints as to where to look to debug this would be appreciated.

Also, ofGetFrameNum returns the same value for each update when draw() is not called.

In the long-run I will be moving much of this segmentation / clustering code into its own thread (dual core machine). So if I am just doing too much in update() for ofx, maybe jumping into the threading code is a good idea…

I’ll attach code if requested. Its very ugly at this point, and requires a sequence of 100s of images, uses the Makefile and not code::blocks, depends on ofxCv and you must have openCV compiled with gpu support.

UPDATE:

The bad news is that the point at which draw() stops being called is different depending on the execution of the same binary. So I’m really not sure of how to debug this. Start tearing out code until it stops happening I suppose. For a visual illustration of the problem, see the attached image, where the dashed line shows where update() continues to be called, but draw() stops. UpdateCounter is just an int that gets incremented in update(). I’ll continue testing and report back.

It was not the createRenderUnits() function in the end. I’ll continue to test until I can narrow it down.

Still any thoughts on what *could* cause draw() to stop being called would be helpful…

Ok, so after a week of ripping out all my code I eventually got to an empty project and the issue persisted. So it appears this is a bug, but wanted to post here in case some other poor sap ends up in my situation.

draw() may not be called on some frames if the frame-rate is set to “1”, see the attached example. If you run it for long enough you will see the “draw” STDOUT messages will eventually disappear, but “update” remains. Tested on 0071 and 0074.

emptyExample-debug.zip

is it possible that you are minimizing the window or putting it in the background? on some platforms glut stops calling draw if the window is not visible, which kind of makes sense.

Hi Arturo, we met in Limerick during Tweak a few years ago…

Ugh.

The problem was that I’m running ofx on a fast headless machine, and it was actually the screen-saver that stopped draw from being called.

I wish I thought of this a week ago!

Of course I’ve been working in straight OpenCV until this point in the same manner and never had an issue, of course because everything is rendered to RAM and not the graphics card…