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

jme3test.app.TestApplication hangs with LWJGL3 #1193

Closed
stephengold opened this issue Sep 20, 2019 · 10 comments · Fixed by #1690
Closed

jme3test.app.TestApplication hangs with LWJGL3 #1193

stephengold opened this issue Sep 20, 2019 · 10 comments · Fixed by #1690
Labels
examples specific to the jme3-examples sub-project
Milestone

Comments

@stephengold
Copy link
Member

Current master branch running on Windows:

  • With LWJGL2, TestApplication completes in < 20 seconds without user input, after displaying a black window and a black fullscreen.
  • With LWJGL3, TestApplication displays the black window, then waits for the user to close the window. If the user closes the window, it pauses, displays the black fullscreen, and hangs. ALT-Tab is required to regain control.
@stephengold
Copy link
Member Author

Observed similar behaviour on Linux.

@louhy
Copy link
Contributor

louhy commented Sep 21, 2019

I get the same result here on Linux. Curiosity struck so here's an analysis.

TLDR: It seems to me the test is incompatible with the way the LWJGL3 context class works (LwjglWindow.java). LWJGL2 creates a separate thread for rendering loop, 3 uses the current
(test!) thread for the rendering loop - so obviously, it blocks.

That's probably all that's needed, but here's my original verbose version:

This test expects the current thread to be allowed to continue after calling start() (which eventually calls context.create()). That's fine for LWJGL2, which looks like this (see: LwjglDisplay.java):

    public void create(boolean waitFor){
        if (created.get()){
            logger.warning("create() called when display is already created!");
            return;
        }
        new Thread(this, THREAD_NAME).start();
        if (waitFor)
            waitFor(true);
    }

But with LWJGL3 this is what it does (see: LwjglWindow.java):

    public void create(boolean waitFor) {
        if (created.get()) {
            LOGGER.warning("create() called when display is already created!");
            return;
        }
        // NOTE: this is required for Mac OS X!
        mainThread = Thread.currentThread();
        run();
    }

That run() never lets the current thread continue on (rendering loop), so the test gets stuck. Closing the window I guess kills the context or something, and apparently breaks it out of the loop in run(). Fullscreen there's no window to close, so it gets "stuck".

So I think due to the way the context classes work, I would say this test is just fundamentally incompatible with LWJGL3.

If the test can be made specific to an LWJGL version, I would say this should be a test for 2 only.

@louhy
Copy link
Contributor

louhy commented Sep 21, 2019

Just to see what happens I tried having the LWJGL3 class create a new thread like 2 does, it passes the test and seems to work fine (Linux).

I see the "required for Mac" comment... wouldn't be hard to do an OS-specific if so that it behaves the same with other OSes. But just to make the test pass, I'm going to assume that's not worth doing.

But I guess that Mac hack is really why the test fails.

@MeFisto94
Copy link
Member

This is a manifestation of yet another problem with LWJGL3. You even need some weird jvm launch argument for mac os, so I guess even with that hack the test would fail.
@riccardobl had an approach at fixing this, it was also related to the settings dialog and all weird hacks, so we should maybe fix this all for once.

@MeFisto94
Copy link
Member

Found something riccardobl@0763be5
We should set up a dedicated issue and work on lwjgl3 somehow to finally make it good. The attached milestone is only a part of all problems.

@stephengold
Copy link
Member Author

Transitioning the Engine to LWJGL3 should be one of the goals of the 3.3.0 release.

I'm not convinced LWJGL3 needs its own milestone; perhaps a GitHub label would make more sense. A GitHub issue or pull request can only have at most one milestone, but it can have many labels.

@louhy
Copy link
Contributor

louhy commented Sep 21, 2019

Yeah there's definitely some work before v3 compatibility is on par wth v2. That settings dialog patch may work fine for pre-Java 9 but I have strong doubts it'd be future proof, since it uses stuff like sun.awt.SunToolkit, all that Sun stuff is supposed to be private API. ☹️

It's a shame there doesn't seem to be much interest in introducing a JavaFX dependency and dropping Swing, it might be a fun mini-project to rebuild the whole dialog with JFX, and try to knock that kind of issue out at the same time.

Edit: Just in case it matters at some point, just realized there's also LwjglWindowVR.java which also will hijack the test thread like LWJGL3 does.

@tlf30
Copy link
Contributor

tlf30 commented Nov 4, 2019

I believe this is related to #1048

@stephengold
Copy link
Member Author

Just confirmed that the issue is still present in v3.4.0-beta4.

bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 24, 2021
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().
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 25, 2021
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.
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 25, 2021
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.
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 25, 2021
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.
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 25, 2021
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Nov 25, 2021
stephengold added a commit that referenced this issue Nov 30, 2021
* This is a very simple addition. It allows a person to set 3 variables 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.

* formatting and comments changes.

* jme3test.app.TestApplication hangs with LWJGL3 #1193
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().

* removing unwanted changes, since you can't do multiple pull requests at once.

* formatting issues.

* changed parameter naming to be more consistency with other items.

* jme3test.app.TestApplication hangs with LWJGL3 #1193

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.

* jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)

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.

* removing unwanted changes.

* AppSettings:  enhance the new javadoc

* AppSettings:  capitalize Window{X/Y}Position consistent w/other settings

* LwjglWindow:  convert tabs to spaces

* AppSettings:  re-arrange @see tags in javadoc

Co-authored-by: Stephen Gold <sgold@sonic.net>
bob0bob added a commit to bob0bob/jmonkeyengine that referenced this issue Dec 1, 2021
…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 added a commit to bob0bob/jmonkeyengine that referenced this issue Dec 2, 2021
…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
stephengold added a commit that referenced this issue Dec 6, 2021
* This is a very simple addition. It allows a person to set 3 variables 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.

* formatting and comments changes.

* jme3test.app.TestApplication hangs with LWJGL3 #1193
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().

* removing unwanted changes, since you can't do multiple pull requests at once.

* formatting issues.

* changed parameter naming to be more consistency with other items.

* jme3test.app.TestApplication hangs with LWJGL3 #1193

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.

* jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)

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.

* removing unwanted changes.

* AppSettings:  enhance the new javadoc

* AppSettings:  capitalize Window{X/Y}Position consistent w/other settings

* LwjglWindow:  convert tabs to spaces

* AppSettings:  re-arrange @see tags in javadoc

* 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

* 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

* Removed the string compare to determine if it is a Mac OS.  Using LWJLG3 class that determines this instead.

* Making changes for Mac os.  The AWT examples will not work under Mac but the Linux and Windows version will start to work.

* added braces that are need for formatting.

* LwjglWindow:  copyright year, log message, correct indents and braces

Co-authored-by: Stephen Gold <sgold@sonic.net>
@stephengold stephengold modified the milestones: LWJGLv3 Issues, v3.5.0 Dec 6, 2021
@stephengold stephengold added examples specific to the jme3-examples sub-project and removed To be investigated labels Dec 6, 2021
@stephengold
Copy link
Member Author

I verified the fix on Windows 10 and on Linux, with LWJGL 3.3.0, both from the test chooser and executing TestApplication as a standalone app. The only weirdness was on Linux with the test chooser:

Dec 08, 2021 2:18:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Dec 08, 2021 2:18:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 2
Destroying offscreen buffer
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  20 (X_GetProperty)
  Resource id in failed request:  0x4c00007
  Serial number of failed request:  1598
  Current serial number in output stream:  1598

stephengold added a commit that referenced this issue Dec 9, 2021
…1657  (#1696)

* This is a very simple addition. It allows a person to set 3 variables 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.

* formatting and comments changes.

* jme3test.app.TestApplication hangs with LWJGL3 #1193
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().

* removing unwanted changes, since you can't do multiple pull requests at once.

* formatting issues.

* changed parameter naming to be more consistency with other items.

* jme3test.app.TestApplication hangs with LWJGL3 #1193

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.

* jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)

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.

* removing unwanted changes.

* AppSettings:  enhance the new javadoc

* AppSettings:  capitalize Window{X/Y}Position consistent w/other settings

* LwjglWindow:  convert tabs to spaces

* AppSettings:  re-arrange @see tags in javadoc

* using deprecated FrameBuffer methods in jme3-core and jme3-desktop #1657

Updating all references to setDepthTexture  and setColorTexture from old system to the new system.

* Removing unused imports.

* missed an unused import.

* FrameBuffer:  improve formatting of the added sourcecode

* tweak the whitespace

Co-authored-by: Stephen Gold <sgold@sonic.net>
stephengold added a commit that referenced this issue Jan 3, 2022
* This is a very simple addition. It allows a person to set 3 variables 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.

* formatting and comments changes.

* jme3test.app.TestApplication hangs with LWJGL3 #1193
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().

* removing unwanted changes, since you can't do multiple pull requests at once.

* formatting issues.

* changed parameter naming to be more consistency with other items.

* jme3test.app.TestApplication hangs with LWJGL3 #1193

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.

* jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)

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.

* removing unwanted changes.

* AppSettings:  enhance the new javadoc

* AppSettings:  capitalize Window{X/Y}Position consistent w/other settings

* LwjglWindow:  convert tabs to spaces

* AppSettings:  re-arrange @see tags in javadoc

* TestPostWater issue #1699

Changed it so when you go under water to turn off reverb.   I turned off the Low Filter because it is not needed with Reverb is turned off.

* Added a feature to leave dry filter on/off.  Also put on the screen other hot keys this demo supports.

* type preventing input to work correctly.

* more formattings changes.

* TestPostWater:  standardize key names

* TestPostWater:  correct key assignements that were swapped

* TestPostWater:  organize imports per the style guide

* TestPostWater:  whitespace

* TestPostWater:  change useDryFilter logic so the 4 key has prompt effect

Co-authored-by: Stephen Gold <sgold@sonic.net>
stephengold added a commit that referenced this issue Jan 9, 2022
* This is a very simple addition. It allows a person to set 3 variables 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.

* formatting and comments changes.

* jme3test.app.TestApplication hangs with LWJGL3 #1193
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().

* removing unwanted changes, since you can't do multiple pull requests at once.

* formatting issues.

* changed parameter naming to be more consistency with other items.

* jme3test.app.TestApplication hangs with LWJGL3 #1193

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.

* jme3test.app.TestApplication hangs with LWJGL3 #1193 (#3)

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.

* removing unwanted changes.

* AppSettings:  enhance the new javadoc

* AppSettings:  capitalize Window{X/Y}Position consistent w/other settings

* LwjglWindow:  convert tabs to spaces

* AppSettings:  re-arrange @see tags in javadoc

* TestPostWater issue #1699

Changed it so when you go under water to turn off reverb.   I turned off the Low Filter because it is not needed with Reverb is turned off.

* Added a feature to leave dry filter on/off.  Also put on the screen other hot keys this demo supports.

* type preventing input to work correctly.

* more formattings changes.

* TestPostWater:  standardize key names

* TestPostWater:  correct key assignements that were swapped

* TestPostWater:  organize imports per the style guide

* TestPostWater:  whitespace

* TestPostWater:  change useDryFilter logic so the 4 key has prompt effect

Co-authored-by: Stephen Gold <sgold@sonic.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples specific to the jme3-examples sub-project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants