Window focus when files have been created

Started by Obsyd, June 29, 2016, 09:55:57

Previous topic - Next topic

Obsyd

Hello there!

My system: OS X 10.11.5 with an AMD 280X

Whenever I create a few files before I create the LWJGL window. The window will not be focused (the window shows up behind the netbeans window) and no WindowFocusCallback callbacks show up. When this happens input acts weird (for example: the mouse coords only update if I hold down the right click) and if I maximize the window (green fullscreen maximize on OSX) I get these errors:
(these errors only happen if I create files before I create the LWGL window)

Jun 29 11:50:37  java[2251] <Error>: CGWindowContextCreate: failed to create window context delegate.
Jun 29 11:50:37  java[2251] <Error>: CGWindowContextCreate: failed to create window context delegate.
Jun 29 11:50:37  java[2251] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextResetCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextResetClip: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextScaleCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: clip: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Jun 29 11:50:37  java[2251] <Error>: CGContextSynchronize: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.


The files I create are not open. They are closed properly. During file creation I use ImageIO and simple FileOutputStream with flush and close. And they are created properly.
The same thing happens if I run my app from netbeans and from the terminal.
The logic() part of the app runs fine. I see my performance charts being updated nicely. The only problem is that the window does not seem to be focused properly.

Thank you!


Obsyd

I tried to force glfwFocusWindow in my main loop. It did not help.

Obsyd

While looking (profiling) at the active threads. When the problem occurs I see an additional thread called Java2D Disposer running along all other threads. When I don't create files this thread does not fire up. It probably has to do with something related to ImageIO right?

Cornix

I think ImageIO is connected to the AWT. On MacOS you are not allowed to have the AWT and GLFW running simultaneously for reasons connected to the -XStartOnFirstThread stuff. I dont know if using ImageIO is enough to trigger the problems but judging from what you are describing I guess it is.

Obsyd

That's what I'm thinking too. But the only thing I do is a simple ImageIO.read.

CoDi

Try to call this before doing anything ImageIO:

System.setProperty("java.awt.headless", "true");

Obsyd

If I specify headless GLFW throws nullpointers.

java.lang.NullPointerException
	at org.lwjgl.system.Checks.checkPointer(Checks.java:103)
	at org.lwjgl.glfw.GLFW.nglfwGetVideoMode(GLFW.java:1202)
	at org.lwjgl.glfw.GLFW.glfwGetVideoMode(GLFW.java:1222)

CoDi

Uhm, any other warnings/errors written to the terminal?

I use it the other way around. I create the window first. The file operations (custom libGDX texture packer, which re-packs some sprite atlas on demand) are done in the first "loading screen", so GLFW is initialized and the window is visible when I set awt.headless.

Obsyd

Jun 29 17:05:00  java[1891] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jun 29 17:05:00  java[1891] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.
Jun 29 17:05:00  java[1891] <Warning>: CGSConnectionByID: 0 is not a valid connection ID.

Cornix

I guess a simple example program would be useful to find out what the problem is.

spasi

LWJGL comes with stb bindings, which includes stb_image for reading images and stb_image_write for writing them. They can be used to replace ImageIO, removing the AWT dependency. Using awt.headless on MacOS may work, but it is not guaranteed and not supported by LWJGL in any way.

Obsyd

Sadly I would really like to use ImageIO. I will further investigate the problem to see if maybe it is caused by something else I'm doing. Thank you for the replies guys!

Obsyd

Anyone else having problems extracting the latest nightlies?

spasi

I just tried the latest nightly build (3.0.1 #10) without any issues. What kind of problems are you having?

Obsyd

When I download the latest build the zip is 27MB (used to be less). After I extract it I get a lot of jars and folders.