Calling ofGetScreenWidth() causes massive slow down on Ubuntu


Hi, I found out calling ofGetScreenWidth() or ofGetScreenHeight() causes frame rate to drop to 2~3 fps on Ubuntu.

You can test this by simply adding this code inside update()

cout << "frameRate : " << ofGetFrameRate() << endl;

I use OF_0.9.8_release and I found a relevant commit here.

But the problem still occurred even after applying the fix.
Calling ofGetWidth() or ofGetHeight() didn’t slow down the app though.

I would appreciate if any Linux user can confirm this.
Thanks in advance!

Frame rate drop in linux and windows while using opencv find contours

its probably a driver thing or a GLFWWindow quirk…


I reported this ages ago, I can’t remember where.

Yes I can totally confirm it. It’s fixed in 0.10.0 (which hasn’t been released yet but you can get the latest from GitHub) but not in 0.9.8. In fact it affects several 0.9 versions, I can’t remember when it was introduced.

The only thing you can do to work around it at the moment is run the app in game mode, e.g.



It is always advisable to set variables in the setup function, example:

int w,h,ws,hs;

void setup()
          w = ofGetWidth();
          h = ofGetHeight();
          ws = ofGetScreenWidth();
          hs  = ofGetScreenHeight();


@kashim this doesn’t solve the bug. There are a number of functions which rely on ofGetWidth() internal IIRC. I don’t remember being able to find a work-around for a complex app other than the one above.


Just following this up, there’s an easy fix to this if you follow the thread here:

The solution is to apply the commit fixing it as a patch in the OF root directory:
patch -p1 < 0001-several-fixes-for-glfw-and-main-loop.patch
and then recompile OF


Hi, did you try my test code to see if it is fixed?

cout << "frameRate : " << ofGetFrameRate() << endl;

I just applied the fix with the patch and recompiled OF but I still get 2~3 fps. I tested this on Ubuntu 16.04.

And what Linux OS do you use? Thanks in advance.

How to install LPMT on ubuntu?

Yes, I put that code into the update() function of an empty project and got 60fps.

The fullscreen fps slowdown is related to the ofGetWidth() / ofGetScreenwidth() bug which is GLFW related.

I’m on Ubuntu 16.04 LTS, and using an Intel HD4400