Hello Guest

Window focus when files have been created

  • 18 Replies
  • 7509 Views
*

Offline Obsyd

  • **
  • 71
Window focus when files have been created
« on: June 29, 2016, 09:55:57 »
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)

Code: [Select]
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!

« Last Edit: June 29, 2016, 09:59:19 by Obsyd »

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #1 on: June 29, 2016, 10:02:53 »
I tried to force glfwFocusWindow in my main loop. It did not help.

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #2 on: June 29, 2016, 10:17:03 »
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?

*

Offline Cornix

  • *****
  • 487
Re: Window focus when files have been created
« Reply #3 on: June 29, 2016, 13:15:40 »
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.

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #4 on: June 29, 2016, 13:40:59 »
That's what I'm thinking too. But the only thing I do is a simple ImageIO.read.

*

Offline CoDi

  • *
  • 49
Re: Window focus when files have been created
« Reply #5 on: June 29, 2016, 14:10:06 »
Try to call this before doing anything ImageIO:

Code: [Select]
System.setProperty("java.awt.headless", "true");

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #6 on: June 29, 2016, 14:18:32 »
If I specify headless GLFW throws nullpointers.

Code: [Select]
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)

*

Offline CoDi

  • *
  • 49
Re: Window focus when files have been created
« Reply #7 on: June 29, 2016, 14:39:21 »
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.

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #8 on: June 29, 2016, 15:05:42 »
Code: [Select]
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.

*

Offline Cornix

  • *****
  • 487
Re: Window focus when files have been created
« Reply #9 on: June 29, 2016, 15:22:37 »
I guess a simple example program would be useful to find out what the problem is.

*

Offline spasi

  • *****
  • 2156
    • WebHotelier
Re: Window focus when files have been created
« Reply #10 on: June 29, 2016, 15:30:24 »
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.

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #11 on: June 30, 2016, 06:22:54 »
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!

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #12 on: July 24, 2016, 09:33:14 »
Anyone else having problems extracting the latest nightlies?

*

Offline spasi

  • *****
  • 2156
    • WebHotelier
Re: Window focus when files have been created
« Reply #13 on: July 24, 2016, 11:44:34 »
I just tried the latest nightly build (3.0.1 #10) without any issues. What kind of problems are you having?

*

Offline Obsyd

  • **
  • 71
Re: Window focus when files have been created
« Reply #14 on: July 24, 2016, 12:40:34 »
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.