I’m using Ubuntu 14.04.5 LTS, and I was doing an app in OF rev. 16eca45a1d45a from git
. In this app, I have a small FPS display in ofApp::draw()
, and it was working great.
Then I tried recompiling the app with tag 0.9.3, and suddenly I could notice the FPS display sometimes randomly “freezing” when I click on the app GUI; it looks somewhat like this:
Notice how at a certain point, the FPS stops changing and sort of “freezes”. Then I tried recompiling with OF tag 0.9.0, same thing. Finally I went back to 16eca45a1d45a, and again same thing, and now I can’t get rid of this behavior (the above gif was taken with a OF 16eca45a1d45a based build)
The code for that part is something like in this minimal example:
ofApp.h
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void mousePressed(int x, int y, int button);
};
ofApp.cpp
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofSetFrameRate(60);
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
// ... some other drawing in orig app here ... then:
ofSetColor(ofColor::red);
ofDrawBitmapString( ofToString((ofGetFrameNum() % 2 == 0)?"-":"|"), ofVec2f(0, 32) );
ofFill();
ofSetColor(ofColor::black);
ofDrawRectangle(ofPoint(0,0), 100, 20);
ofNoFill();
ofSetColor(ofColor::green);
ofDrawBitmapString( "FPS: " + ofToString(ofGetFrameRate()), ofVec2f(0, 16));
ofLogNotice() << "d";
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
// simulate "doing something":
float o = 0;
for(int i = 0; i < 10000000; i++) { o += ofRandom(i); }
ofLogNotice() << "mousePressed " << o;
}
Unfortunately, this minimal example does not reproduce the problem, but it shows the actual code for the FPS drawing part.
The strange thing is, even if this freeze happens - the ofApp::draw()
still runs, which is evidenced by the ofLogNotice() << "d";
being output to terminal continuously even when the “freeze” happens in the GUI display (furthermore, note that even when the freeze happens, the framerate is still shown around 60 fps, which means that draw()
s should be running in the background).
It’s as if just the particular draw commands for the FPS are skipped, resulting with a frozen appearance, while the rest of the OF engine actually works ?!
Could this be a problem with X window drawing events or something? The only thing I remember changing recently with the graphics, is that Ubuntu 14.04.5 LTS bumped to a new kernel (4.4.0-34-generic), after which I noticed that lightdm-gtk-greeter
from MATE desktop flashes when first being shown at start after reboot (and this occurs now in both 4.4.0-34-generic and the previous 3.19.0-66-generic, whereas it didn’t occur previously when there was only 3.* series Linux kernel).
Has anyone else experienced something like this? And would anyone know how to get back to the proper frame drawing behavior that I used to experience previously for my Linux desktop builds?