my application quits unexpectedly if the monitor/display has not powered up

I have a simple video player application that makes use of ofQTKitPlayer. If the application starts up whilst the monitor has yet to power up, the program exits displaying the error “appName quit unexpectedly”, furthermore one of my machines is meant to be headless so this is an even bigger issue for that one.

How can I solve this?

I’m running OSX 10.8.3, and the machines are Mini’s.

Thanks,
David

I’m having the exact same issue today! hah

It appears to be an issue with the switch to GLFW from GLUT for the OF rendering backend, at least thats what my program is throwing (I’m just drawing bitmap strings)

  
//------------------------------------------------------------  
void ofAppGLFWWindow::setupOpenGL(int w, int h, int screenMode){  
  
	requestedWidth = w;  
	requestedHeight = h;  
  
  
	if(!glfwInit( )){ //THIS throws an exec bad access if a monitor isn't connected but i'm screen shared into the mac mini  
		ofLogError("ofAppGLFWWindow") << "couldn't init GLFW";  
		return;  
	}  

I think setting it to be headless is the way to go…you might need to do some other method to detect if a monitor is connected and then start your app…urg

I was able to do this for my headless app, doesnt help you with the other one if the monitor isn’t connected yet though. Only way I can think of is some kind of shell script/cron job that keeps trying to open a dummy app and doesn’t signal your app to open until that one successfully opens:

https://github.com/robotconscience/ofAppNoWindow

And you just have to change one line in ofNoWindowRunner to work with the new GLFW renderer:

void ofSetupNoWindow(int w, int h, int screenMode){
#ifdef TARGET_OF_IPHONE
window = ofPtr(new ofAppiPhoneWindow());
#elif defined TARGET_ANDROID
window = ofPtr(new ofAppAndroidWindow());
#else
window = ofPtr(new ofAppGLFWWindow()); ///CHANGE THIS - usually says ofAppGlutWindow
#endif

ofSetupNoWindow(window,w,h,screenMode);
}

Ok…the other option for you is to switch back to GLUT window, make your main app look like the old style and give that a shot, it worked for me…test by screen sharing into the mac with no monitor connected…an example for you:

  
  
#include "ofMain.h"  
#include "ofApp.h"  
#include "ofAppGlutWindow.h"  
//========================================================================  
int main( ){  
    ofAppGlutWindow window;  
     
    ofSetupOpenGL(&window, 1024, 768, OF_WINDOW);  
	// this kicks off the running of my app  
	// can be OF_WINDOW or OF_FULLSCREEN  
	// pass in width and height too:  
	ofRunApp( new ofApp());  
  
}  
  

Switching back to the GLUT window didn’t seem to work for me.

My current solution is to use a launchd script to restart the app, and my headless app doesn’t actually need a display.

  
<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "[http://www.apple.com/DTDs/PropertyList-1.0.dtd">](http://www.apple.com/DTDs/PropertyList-1.0.dtd">)  
<plist version="1.0">  
<dict>  
        <key>RunAtLoad</key>    
        <true/>  
        <key>KeepAlive</key>  
        <true/>  
        <key>Label</key>  
        <string>MTScreen.restart</string>  
        <key>ProgramArguments</key>  
        <array>  
                <string>Applications/MTScreen.app/Contents/MacOS/MTscreen</string>  
        </array>  
</dict>  
</plist>  

http://apple.stackexchange.com/questions/837/automatically-relaunch-a-closed-application

In case it inspires something - not for nothing, but I think OS X powers down a GPU that does not have a display attached; in which case your app might be crashing because it cannot create the context it is expecting. If you post a backtrace we might be able to better diagnose. You might try a terminator of some sort like the fit-headless to force the GPU to power up.