Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS (or LibGDX) not happy on Macs? Threading issue related to UI rendering / the game splash screen? #414

Open
Cervator opened this issue May 27, 2019 · 2 comments
Labels

Comments

@Cervator
Copy link
Member

What you were trying to do

Update and run DS on my Macbook while out of town. Would be nice to know what happens on other OSes

What actually happened

Angry red text (see below). Some of it seems to suggest a JVM flag may be able to help, or to avoid certain other libs?

How to reproduce

  • Be on a later Java (10 in this case - unsure about 9, 11, or 12)
  • Possibly be on a Mac
  • Simply run the game

Log details and game version

DEBUG [Thread-0] (PermissionSet.java:186) - Added API classes 'org.destinationsol.files.*'
DEBUG [Thread-0] (PermissionSet.java:186) - Added API classes 'org.destinationsol.game.input.*'
DEBUG [Thread-0] (ModuleClassLoader.java:83) - Module path: /Users/cervator/dev/terasology/git_ws/DestinationSol/out/production/engine
 WARN [Thread-0] (Reflections.java:181) - given scan urls are empty. set urls in the configuration
2019-05-27 19:08:49.931 java[27529:613056] pid(27529)/euid(502) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!
2019-05-27 19:08:50.029 java[27529:613056] WARNING: NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future. Called from (
	0   AppKit                              0x00007fff468667eb -[NSWindow(NSWindow_Theme) _postWindowNeedsToResetDragMarginsUnlessPostingDisabled] + 378
	1   AppKit                              0x00007fff46863bdb -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1479
	2   AppKit                              0x00007fff4686360e -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
	3   libglfw.dylib                       0x00000001307d90c9 libglfw.dylib + 57545
	4   libglfw.dylib                       0x00000001307d3a5b libglfw.dylib + 35419
	5   ???                                 0x000000011ad3ab50 0x0 + 4745046864
	6   ???                                 0x000000011ad34a50 0x0 + 4745022032
)
Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.lwjgl.glfw.GLFW.glfwShowWindow(GLFW.java:2149)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.setVisible(Lwjgl3Window.java:234)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.createWindow(Lwjgl3Application.java:393)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.createWindow(Lwjgl3Application.java:379)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:108)
	at org.destinationsol.desktop.SolDesktop.main(SolDesktop.java:145)
Caused by: java.lang.IllegalStateException: Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized.
	at org.lwjgl.glfw.EventLoop$OnScreen.<clinit>(EventLoop.java:63)
	... 6 more
AL lib: (EE) alc_cleanup: 1 device not closed

Process finished with exit code 1

Computer details

  • Macbook Pro, running Mojave 10.14.5. Really wanted to write Mojava. I don't know Macs.
  • Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
@Cervator Cervator changed the title DS (or LibGDX) not happy on later Java versions? 10 on Mac seems to cause a failure DS (or LibGDX) not happy on Macs? Threading issue related to UI rendering? Jun 2, 2019
@Cervator
Copy link
Member Author

Cervator commented Jun 2, 2019

Update: Same situation with a Java 8 on the same machine. After digging around a bit and trying the JVM flag from https://stackoverflow.com/questions/37978702/glfw-engine-and-the-main-thread-issue-intellij the flag alone didn't help but a suspicion that our splash screen might cause a non-main thread to get into rendering I tried the -noSplash game argument as well which allowed the game to launch.

It still crashed on exit but ... that beats the former state! Especially with #415 now letting the game launch normally again. I'm going to temporarily make that flag default so resolving this issue should then undo that again and allow the working splash screen to pop up normally.

Exit crash (from a Java dump file, matches part of the snippet above):

java.lang.ExceptionInInitializerError
	at org.lwjgl.glfw.GLFW.glfwShowWindow(GLFW.java:2149)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.setVisible(Lwjgl3Window.java:234)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.createWindow(Lwjgl3Application.java:393)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.createWindow(Lwjgl3Application.java:379)
	at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:108)
	at org.destinationsol.desktop.SolDesktop.main(SolDesktop.java:145)
Caused by: java.lang.IllegalStateException: Please run the JVM with -XstartOnFirstThread and make sure a window toolkit other than GLFW (e.g. AWT or JavaFX) is not initialized.
	at org.lwjgl.glfw.EventLoop$OnScreen.<clinit>(EventLoop.java:63)
	... 6 more

Edit: Adding a workaround for this when running from a distributed zip on Macs is proving weirdly difficult. It works if I do not target the embedded JRE - plain java -XstartOnFirstThread -jar libs/solDesktop.jar -noSplash works, whereas lwjreOSX/bin/java -XstartOnFirstThread -jar libs/solDesktop.jar -noSplash ignores the -noSplash arg for some reason?

If we need to retain the -XstartOnFirstThread part then I found a utility snippet we might want to consider to auto-enable that option even if initially running Java without it: http://www.java-gaming.org/topics/starting-jvm-on-mac-with-xstartonfirstthread-programmatically/37697/view.html

Way later edit: wanted to drop in http://forum.lwjgl.org/index.php?topic=6265.0 as I had it open for this topic but forgot the details ...

@Cervator Cervator changed the title DS (or LibGDX) not happy on Macs? Threading issue related to UI rendering? DS (or LibGDX) not happy on Macs? Threading issue related to UI rendering / the game splash screen? Jun 2, 2019
@Cervator Cervator added the bug label Jun 2, 2019
Cervator added a commit that referenced this issue Jun 2, 2019
…ally elsewhere)

Breaks use of embedded JRE on Macs which needs to be re-enabled when the splash mystery is puzzled out
BenjaminAmos pushed a commit to BenjaminAmos/DestinationSol that referenced this issue Feb 18, 2020
…c (and partially elsewhere)

Breaks use of embedded JRE on Macs which needs to be re-enabled when the splash mystery is puzzled out
@BenjaminAmos
Copy link
Contributor

It seems like the recently-released libGDX 1.11.0 might help fix this issue? It adds a new gdx-lwjgl3-glfw-awt-macos extension which may remove need for a work-around (https://libgdx.com/news/2022/05/gdx-1-11).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants