Skip to content

Conversation

@bob0bob
Copy link
Contributor

@bob0bob bob0bob commented Dec 1, 2021

TestAWTPanels hangs with LWJGL v3 #1558 / jme3test.app.TestApplication hangs with LWJGL3 #1193

Made LWJGL3-JME to launch in the same way the LWJGL2-JME launches. This always Windows and Linux to run, still needs testing on Max OS X

bob0bob and others added 18 commits November 21, 2021 23:33
… in AppSettings. ‘CenterWindow’, ‘WindowXPosition’ and ‘WindowYPosition’ variables. This way these variable will be saved in the profile when the profile is saved, and be reloaded. I added ‘CenterWindow’ to be added with a ‘true’ value for the default value so it will run just like it did before.

But if you set ‘CenterWindow’ to ‘false’ then inside LwjglWindow.java (lwjgl3 code) it will look at these new values, it will determine to center the window or use the position values to place the window back at the location the user last moved it to.

Of course, these values are only updated if the “program” updates this value. So if you want to save screen position, you can save them on closing to and on restart put the window back into the same location.
LWJGL3-JME library would block the current thread when executing LWJGL3.    Instead of calling run() that is blocking,  made it work like LWJGL2-JME library when they start it as a thread so run gets called. I commented out the run() function and replaced it with Thread.start().
LWJGL3-JME projects was doing a call that is blocking the current thread.  I changed it to match how LWJGL2-JME project launches the Context Window.
LWJGL3-JME projects was doing a call that is blocking the current thread.  I changed it to match how LWJGL2-JME project launches the Context Window.
…TestApplication hangs with LWJGL3 jMonkeyEngine#1193

Made LWJGL3-JME to launch in the same way the LWJGL2-JME launches.  This always Windows and Linux to run, still needs testing on Max OS X
@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 1, 2021

This is also related to issue jme-lwjgl3 - bug for starting app #1514

@Jeddic
Copy link
Contributor

Jeddic commented Dec 1, 2021

From what I can tell you just reverted the changes? I can already tell you this breaks osx which is why it was changed in the first place.

…estApplication hangs with LWJGL3 jMonkeyEngine#1193

Made LWJGL3-JME to launch in the same way the LWJGL2-JME launches.  This always Windows and Linux to run, still needs testing on Max OS X
@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 2, 2021

I made more changes, based on the history of the changes and other issues about this issue. It does end up checking to see if it is a Mac and do something else. This is solution I'm using on my engine, it needs to be tested but I worry there is not anyone to test for it. I will cross my fingers for one to step up to test.

@pspeed42
Copy link
Contributor

pspeed42 commented Dec 2, 2021

We should try to come up with code that doesn't use "magic guess the OS" string checks. Even if that means changing the semantics of what start() means.

@stephengold
Copy link
Member

Sorry if this is a stupid question, but why use mainThread.run() instead of mainThread.start()?

@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 2, 2021

I found a way to check from inside LWJGL3, they have a call to return a ENUM for the 3 types of hardware that is support. I will put that in but last night my eclipse build started to mess up and I couldn't get it to run in debug to verify it.

The enum returns, WINDOWS, LINUX or MAC.

They even have a class to verify it is running on the main thread and return false is not, so you can throw an exception.

@stephengold stephengold added this to the v3.5.0 milestone Dec 2, 2021
@Jeddic
Copy link
Contributor

Jeddic commented Dec 2, 2021

I just confirmed that this crashes on OSX.

@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 3, 2021

I made changes to remove the string comparison. This does fix the Windows and Linux. Jeddic, if you have a MAC, Please look into a solution for Mac. Looking into the JME-LWJGL2 library the create() method ends up doing the same for the Mac.

This is moving forward to getting LWJGL3 functioning. I'm not sure what "CRASH" means, because it does the run() call on the current thread. If anything this is not a solution for Mac, but for other 2 OS.

@stephengold
Copy link
Member

@Jeddic next time, please copy/paste the stack trace

@Jeddic
Copy link
Contributor

Jeddic commented Dec 3, 2021

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ExceptionInInitializerError
	at org.lwjgl.glfw.GLFW.glfwInit(GLFW.java:1046)
	at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:197)
	at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:515)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:650)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: GLFW may only be used on the main thread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.
	at org.lwjgl.glfw.EventLoop.<clinit>(EventLoop.java:30)
	... 5 more

There you go.

@Jeddic
Copy link
Contributor

Jeddic commented Dec 3, 2021

So I tested the current version and it is close, but calling mainthread.run() won't work. There isn't a runnable assigned so it immediately returns and closes the application. Just calling run() directly works for me.

…ut the Linux and Windows version will start to work.
@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 3, 2021

Jeddic, thanks. I but the run() call back for MacOS. This will not solve the issue for Mac and AWT but will for Linux and Windows.

@Jeddic
Copy link
Contributor

Jeddic commented Dec 3, 2021

Yah, fixing it for osx will probably take changing the canvas to use the lwjgl-awt project. Let me know if there is anything else that needs to be tested.

@stephengold
Copy link
Member

If this PR doesn't solve the issue for macOS, then why not remove the if (Platform.get() == Platform.MACOSX) { clause?

Also, our preferred Java style specifies that braces are used with if statements, even when the body is empty or contains only a single statement, so the if (waitfor) clause(s) need braces.

@Jeddic
Copy link
Contributor

Jeddic commented Dec 6, 2021

Well, this pull request should fix the issue for windows / linux. The clause is there specifically so it doesn't break macOS in the process.

@bob0bob
Copy link
Contributor Author

bob0bob commented Dec 6, 2021

I added the braces for the correct coding.

We have to leave in the check for MAC, because the Mac needs the run() call. That call is blocking and non-returning. But with the thread().start(), that is a non-blocking call that will allow the return so the rest of the code gets executed after the call to app.start() in main.

@stephengold stephengold linked an issue Dec 6, 2021 that may be closed by this pull request
@stephengold stephengold changed the title Lwjgl3 hangs #1558 / 1193 fix issues #1158 and #1193 for Linux/Windows (LWJGL v3 hangs) Dec 6, 2021
@stephengold stephengold changed the title fix issues #1158 and #1193 for Linux/Windows (LWJGL v3 hangs) fix issues #1193 and #1558 for Linux/Windows (LWJGL v3 hangs) Dec 6, 2021
@stephengold stephengold linked an issue Dec 6, 2021 that may be closed by this pull request
@stephengold stephengold merged commit 38752ea into jMonkeyEngine:master Dec 6, 2021
@stephengold
Copy link
Member

Rather than slog through another round of review, I fixed a couple minor issues and integrated the PR.

Thank you for your contribution to the Engine!

@stephengold stephengold added the defect Something that is supposed to work, but doesn't. Less severe than a "bug" label Dec 6, 2021
@stephengold
Copy link
Member

Now TestAWTPanels is broken in a new and different way. See issue #1558 for details.

@bob0bob bob0bob deleted the LWJGL3_Hangs_#1558 branch December 9, 2021 03:01
@bob0bob
Copy link
Contributor Author

bob0bob commented Jan 4, 2022

Okay, I checked in the changes and tested it against the example from the forum where it is hanging.

@bob0bob
Copy link
Contributor Author

bob0bob commented Jan 4, 2022

Do I start a new merge request to get the changes over since it has already been merged.

@Ali-RS
Copy link
Member

Ali-RS commented Jan 4, 2022

No need for that, it is already fixed in JME v3.5.0-beta5. See #1722.
Sorry for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defect Something that is supposed to work, but doesn't. Less severe than a "bug"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jme3test.app.TestApplication hangs with LWJGL3

5 participants