OSX: stuck in full-screen after java exception

Usually, when running full-screen on OSX, it is always possible to leave the app by using cmd-Q.

The problem is when some uncaught Java exception occurs: cmd-Q is not working anymore and the only possibility I found to leave was to shut-down the machine.

Any clues?

Thanks,
Ariel
http://chronotext.org

Catch your exceptions so that the execution of your program doesn’t halt, or do something in your main method like:


// setup windows/fullscreen - which should also check for exceptions, but I won't go into that
try {
   while(true) {
      // do game, if quit requested break out of loop
   }
} finally {
  // tear down fullscreen
}

The point here is not how to protect users from uncaught exception. It is more like: how to make a developer’s life easier, in a world where unpredictable exceptions occur on a daily basis, while developing…

But I see your point: you mean that by putting the “main loop” inside try/catch should catch most of the exceptions and exit gracefully?
Ok, I accept it, but still I wonder what would happen if some exception take place inside another thread (e.g. some http stuff…)

And from a Jogl developer standpoint, it is strange at the first place that cmd-Q cease to work at some point.

Could it be related to the way LWJGL treats full-screen windows on OSX? (and to the point that no “system overlays” appear on top of the screen, e.g. when changing the Mac’s volume?..)

I also had the problem a couple of times and just couldn’t figure out how to get back to my desktop.
So I’m also looking for a keyboard-combo or something to close the Game. Maybe somebody has an Idea?

And since it also happens with Games from other people I can’t change the code, so I’m looking for a way to close the Game without changing the Code. :slight_smile:

There is a lot of weird things going on with Mac’s and windowing. When using LWJGL, I do not remember Cmd-Q ever working, I thought it was something that AWT added. In my experience, most fullscreen games in Mac (such as WoW) don’t respond to Cmd-Q when in fullscreen mode.

Writing just a bit of code to exit gracefully will help with development and will be nicer for users at the same time, although stopping the exceptions would be best :slight_smile:

Actually, Apple provides an API for manually overriding what Command Q does. Take a look at http://developer.apple.com/library/mac/#documentation/Java/Reference/JavaSE6_AppleExtensionsRef/api/index.html . So you can just exit fullscreen mode when handling the quit event.

Thanks, Mr. Gol, for the info but I’m not sure it is relevant.

Right now, the situation with LWJGL on OSX is that the application exits automatically when cmd-Q is pressed.
You don’t have to code anything fancy for that, it behaves just like Alt-F4 on Windows…

The problem is when some uncaught exception occurs: cmd-Q is not working anymore.
I was hoping I could bring Eclipse’s window to the front by using Alt-Tab, but no: I’m stuck in full-screen and the only way out is to turn off the Mac.

Right now, it seems like there is no magic-trick to solve that situation (i.e. without the need to do some preemptive exception catching…)

When an uncaught exception occurs it’s probably the case you accidentally leave your Cmd-Q processing loop and never actually leave the JVM. Not sure though, my Mac’s dead so can’t test :confused:
Remember in LWJGL, Cmd-Q is actually processed by you not by anything else. You have to explicitly detect it and call System.exit()

Cas :slight_smile:

Thanks, and well, it looks like I was not totally aware of this fact…
Part of digesting the LWJGL pill I guess :slight_smile: