Login  Register

Re: Where/when is it ok to call setFullscreen()?

Posted by Sven Gothel on Aug 19, 2014; 12:02am
URL: https://forum.jogamp.org/Where-when-is-it-ok-to-call-setFullscreen-tp4032828p4032830.html

On 08/19/2014 01:18 AM, Marian Schedenig [via jogamp] wrote:

> I allow users to toggle my game's fullscreen mode from an ingame menu. When
> the fullscreen button is clicked, I call:
>
> glWindow.setUndecorated(fullscreen);
> glWindow.setFullscreen(fullscreen);
>
>
> (fullscreen being a boolean variable, of course)
>
> Sometimes this works fine, but often it triggers a lock exception (see below)
> and apparently locks up the animator (I use an FPSAnimator). Resize events
> still update my window, but the animator doesn't.
>
> I do all my own logic from my GLEventListener's display() method. I tried
> disabling the animator before calling setFullscreen() and reenabling it
> afterwards, but it didn't help, probably since setFullscreen() internally
> calls runOnEDTIfAvail() anyway.
>
> This is all on Linux/X11/KDE by the way, I haven't yet tested it on other
> platforms.
>
> Perhaps I'm simply calling setFullscreen() from the wrong location. But in
> that case, where/when *is* the correct time to call it?
Thread (NEWT-EDT) and location seems to be fine,
however an issue w/ the FPSAWTAnimator-Timer0 thread exist.

Of course, it shall not be invoked from the AWT-EDT thread,
*iff* an AWT canvas is involved (e.g. NewtCanvasAWT).

Before we go fullscreen, we ofc attempt to pause the animator
and resume it afterwards - this seems to not work here.

TBH .. our unit tests 'only' test the Animator implementation,
not FPSAnimator, since the latter is inferior (no v-sync .. etc).

Please file a bug report, maybe you can even add a unit test using the
FPSAnimator which reproduces the issue at hand.
You could simply copy one of our fullscreen animator tests.

Q: You use NewtCanvasAWT or a plain GLWindow ?

In case of the latter (GLWindow), you may also give the animator
a hint that no AWT threading issue is involved:
  animator.setModeBits(false, AnimatorBase.MODE_EXPECT_AWT_RENDERING_THREAD);

This will allow the animator to be properly paused and resumed,
i.e. operation can block and wait until completed.
Here the DefaultAnimatorImpl will be used instead of AWTAnimatorImpl,
which is also the default if running AWT-headless or w/o AWT support classes.

However, I guess we should see to even the AWT FPSAnimator issue.

~Sven

>
> Exception in thread "main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0" com.jogamp.opengl.util.AnimatorBase$UncaughtAnimatorException: javax.media.opengl.GLException: Caught RuntimeException: Waited 5000ms for: <7d0e0c8b, 2559b9d1>[count 1, qsz 0, owner <main-Display-.x11_:0-1-EDT-1>] - <main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0> on thread main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0
> at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:84)
> at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:446)
> at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:175)
> at java.util.TimerThread.mainLoop(Timer.java:555)
> at java.util.TimerThread.run(Timer.java:505)
> Caused by: javax.media.opengl.GLException: Caught RuntimeException: Waited 5000ms for: <7d0e0c8b, 2559b9d1>[count 1, qsz 0, owner <main-Display-.x11_:0-1-EDT-1>] - <main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0> on thread main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0
> at javax.media.opengl.GLException.newGLException(GLException.java:75)
> at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1318)
> at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1138)
> at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:666)
> at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:77)
> ... 4 more
> Caused by: java.lang.RuntimeException: Waited 5000ms for: <7d0e0c8b, 2559b9d1>[count 1, qsz 0, owner <main-Display-.x11_:0-1-EDT-1>] - <main-Display-.x11_:0-1-EDT-1-FPSAWTAnimator-Timer0>
> at jogamp.common.util.locks.RecursiveLockImpl01Unfairish.lock(RecursiveLockImpl01Unfairish.java:198)
> at jogamp.nativewindow.ResourceToolkitLock.lock(ResourceToolkitLock.java:56)
> at javax.media.nativewindow.DefaultGraphicsDevice.lock(DefaultGraphicsDevice.java:126)
> at jogamp.newt.driver.x11.DisplayDriver.dispatchMessagesNative(DisplayDriver.java:109)
> at jogamp.newt.WindowImpl$FullScreenAction.run(WindowImpl.java:2347)
> at jogamp.newt.WindowImpl.runOnEDTIfAvail(WindowImpl.java:2123)
> at jogamp.newt.WindowImpl.setFullscreenImpl(WindowImpl.java:2457)
> at jogamp.newt.WindowImpl.setFullscreen(WindowImpl.java:2434)
> at com.jogamp.newt.opengl.GLWindow.setFullscreen(GLWindow.java:432)
>


signature.asc (828 bytes) Download Attachment