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

X Error of failed request: RenderBadPicture (invalid Picture parameter) #149

Closed
bluenote10 opened this issue Mar 5, 2016 · 24 comments
Closed

Comments

@bluenote10
Copy link

I'm currently facing a very weird issue: In one of my projects I'm getting the following error during initialization. My initialization code is pretty much identical to the Pong example code, with added logging statements to see the steps of the initialization:

[LWJGL] Version: 3.0.0b SNAPSHOT
[LWJGL]      OS: Linux v3.13.0-79-generic
[LWJGL]     JRE: 1.8.0_74 amd64
[LWJGL]     JVM: Java HotSpot(TM) 64-Bit Server VM v25.74-b02 by Oracle Corporation
[LWJGL] Loaded library from java.library.path: lwjgl
[LWJGL] MemoryUtil accessor: MemoryAccessorUnsafe
[LWJGL] Loaded native library: lib/native/libjemalloc.so
[LWJGL] MemoryUtil allocator: JEmallocAllocator
 *** glfwInit
[LWJGL] Loaded native library: lib/native/libglfw.so
     glfwInit [done]
 *** setting glfwSetErrorCallback
     setting glfwSetErrorCallback [done]
 *** setting glfwWindowHint
     setting glfwWindowHint [done]
 *** glfwCreateWindow
X Error of failed request:  RenderBadPicture (invalid Picture parameter)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  6 (RenderSetPictureClipRectangles)
  Picture id in failed request: 0x540005e
  Serial number of failed request:  3285
  Current serial number in output stream:  3287
java.lang.RuntimeException: Nonzero exit code returned from runner: 1
    at scala.sys.package$.error(package.scala:27)

The reason for the vague statement "during initialization" is that the error seems to be asynchronous, and it is not always happening in glfwCreateWindow. For instance, this is output of another run, where I somehow made it past the glfwCreateWindow:

< ... as before ... >
 *** setting glfwSetErrorCallback
     setting glfwSetErrorCallback [done]
 *** setting glfwWindowHint
     setting glfwWindowHint [done]
 *** glfwCreateWindow
X Error of failed request:  RenderBadPicture (invalid Picture parameter)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  6 (RenderSetPictureClipRectangles)
  Picture id in failed request: 0x560005d
  Serial number of failed request:  3523
  Current serial number in output stream:  3525
     glfwCreateWindow [done]
 *** glfwMakeContextCurrent
pure virtual method called
terminate called without an active exception
java.lang.RuntimeException: Nonzero exit code returned from runner: 134

Note that the error in this case also comes with an additional pure virtual method called, which is not the case when it happens in other places.

Another example: If I don't call glfwInit right at the start of the main function, the error always seems to be triggered by glfwInit itself, i.e., I do not get to the point of setting the error callback etc. I was actually very surprised to see that the behavior changes depending on whether I place glfwInit before or after the other initialization code, because this other code has nothing to do with OpenGL / native libraries and just initializes a few Java/Scala data structures.

I do get this error with both the latest stable build (build #3.0.0b build 64) and the latest nightly (build #3.0.0 build 41). My system is an Ubuntu 14.04, 64bit, Java 1.8.0_74, Nvidia Geforce GTX 670, Nvidia driver version 352.79.

What makes this issue even more annoying is the fact that it seems to be difficult to reproduce: So far, I get this error only in my main project. I was trying to come up with a minimal example to reproduce it, but in the minimal example the exact same code works. I'm currently trying to add some complexity from the big project to the minimal example to see what may trigger the problem. But even after adding all dependencies and using exactly the same JVM options, I could not reproduce the error so far. I'm now looking into other potential side effects...

I should add: I have just ported the big project from LWJGL 2.9.1 to 3.X for the first time. With 2.9.1 everything was working fine.

Any hints what could possibly go wrong would be highly appreciated.

@bluenote10
Copy link
Author

I have tracked down the problem and can now offer a minimal reproducing example. The problem is caused by a small "loading" splash screen that is shown during the OpenGL initialization. It looks like there are some kind of side effects between LWJGL/GLFW and Java Swing. In can reproduce the problem like this (I hope it is okay to post in Scala, let me know I should provide a Java version):

import java.awt.BorderLayout
import java.awt.Color
import javax.swing.ImageIcon
import javax.swing.JFrame
import javax.swing.JLabel
import org.lwjgl.glfw.GLFW.glfwInit

class SplashScreenMinimal extends JFrame {

  val icon = new ImageIcon(getClass().getClassLoader().getResource("animated.gif"))
  val label = new JLabel(icon)
  getContentPane().add(label, BorderLayout.CENTER)

  // transparent frames must be "undecorated"
  setUndecorated(true)
  // in general the following allows to use transparency in an animated gif,
  // but this seems to trigger the problem:
  setBackground(new Color(0, 0, 0, 0))

  pack()
  setLocationRelativeTo(null)
  setVisible(true)

  def close() {
    setVisible(false)
    dispose()
  }
}

object SplashScreenMinimal {
  def main(args: Array[String]): Unit = {
    val splashscreen = new SplashScreenMinimal()
    // now glfwInit will crash
    glfwInit()
  }
}

It looks like the splash screen must satisfy a few conditions in order to trigger the RenderBadPicture (a regular JFrame is not an issue):

  • The background of the frame must have an alpha value != 255. Not using setBackground at all or setting setBackground(new Color(0, 0, 0, 255)) does not crash, but e.g. setBackground(new Color(0, 0, 0, 254)) fails.
  • Apparently, the frame must display some kind of graphics like an ImageIcon. In my case it was an animated GIF with transparency. It looks like it is not necessary for the GIF to be transparent though (crashed with this one as well). A transparent PNG also seem to crash.

Now the question is: Why and how does LWJGL 3 or GLFW interfere with this Swing stuff? I'm not sure if this really is a LWJGL bug, but at least this code seem to work in general and also with LWJGL 2.

@Spasi
Copy link
Member

Spasi commented Mar 5, 2016

GLFW does not interact with AWT/Swing on Linux. A possible explanation for the crash could be that Swing produces an X error, which is picked up by GLFW and the program aborts. I think this is possible due to how error handling in Xlib works.

I'm afraid I won't have time to look into this any further. Keep in mind that LWJGL 3 does not (officially) support AWT/Swing integration.

I'm wondering though, why do you use a custom JFrame for the splash screen and not the JVM's built-in support? What happens if you replace the JFrame with:

java ... -splash:spinner.gif ...

and call SplashScreen.getSplashScreen().close() after glfwInit()?

@bluenote10
Copy link
Author

Ah I see, now that's a bit tricky. Thanks for the feedback!

I ran some tests with the regular -splash approach and this seems to work fine (it looks like the implementation of SplashScreen does not use any kind of Swing dialog at all, but relies entirely on native functionality).

The reason why I wasn't using a regular splash screen is that the functionality is limited. For instance, I wanted to add a message log to show the steps of the initialization.

Maybe official support for Swing might be a nice feature for the future. My software for instance is a VR-only application. In such a case it might not be unusual to have some kind of traditional UI on the regular screen (showing some status or even for configuration), with the graphics engine running in "direct mode" on the HMD.

@Spasi
Copy link
Member

Spasi commented Mar 6, 2016

The reason why I wasn't using a regular splash screen is that the functionality is limited. For instance, I wanted to add a message log to show the steps of the initialization.

If the initialization process is that long, you could use an undecorated GLFW window as a splash screen. A simple texture and STBTruetype for the text will do just fine.

(Animated GIFs will be tricky though. Will require some internal functions in STBImage to be exposed, let me know if you need it.)

Maybe official support for Swing might be a nice feature for the future.

Please see #101.

There are ways to make AWT/Swing/JavaFX integration work, but the choices are:

  • It only works on specific OSes or under very specific conditions.
  • It has horrible performance.
  • The user has to write a ton of code to get it right.

It's a lot of pain for solutions that don't really satisfy anyone. LWJGL 3 is designed to be extremely lightweight and not make any choices for the user. For example we have JAWT bindings, you can use that to implement LWJGL 2's solution, but it won't be provided out of the box.

My software for instance is a VR-only application. In such a case it might not be unusual to have some kind of traditional UI on the regular screen (showing some status or even for configuration), with the graphics engine running in "direct mode" on the HMD.

The solution I would use and the one I generally recommend when you have separate "scene" and "GUI" windows: use two processes (i.e. two JVM instances), one for each window, and an IPC solution for dispatching messages between them. This way you isolate each windowing system and you can basically do whatever you want, even on OS X (which is the most problematic OS for such things).

@kappaOne
Copy link
Member

kappaOne commented Mar 6, 2016

Another possible solution for showing a splash screen could be using the SWT library instead of AWT/Swing/JavaFX. Its works well with LWJGL3 and supports loadings and displaying animated gifs (or even a native progress bar).

@Spasi Spasi added the 3rd party label Mar 7, 2016
@pierr3
Copy link
Contributor

pierr3 commented May 17, 2016

I have the same problem using the nightly build, my application uses LWJGL to draw a map, and uses Swing GUI to, for instance, allow the user to select the map he wants to display. I have a Swing Dialog before the creation of the glfw window that works fine, but after creating the glfw window, I use events to open other GUIs, such as glfw Key Press callback, despite using the Swing EDT, my application crashes with the same error message a few seconds after the GUI has closed, which is very strange.
That means I can have the Swing Dialog open, I can interact with it, and upon closing it, I can retrieve the data set by the user in the lwjgl thread and update my map accordingly, but after 20-40 seconds, the application crashes:

X Error of failed request: RenderBadPicture (invalid Picture parameter)
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 7 (RenderFreePicture)
Picture id in failed request: 0x400004b
Serial number of failed request: 16948
Current serial number in output stream: 16967

I guess I'm going to have to change my approach to GUIs using LWJGL.

@ShadowLordAlpha
Copy link

@pierr3 could you post a small sample that errors out or can you only get it to happen when you have a large amount of code.

@pierr3
Copy link
Contributor

pierr3 commented May 19, 2016

@ShadowLordAlpha I don't have a small sample, but it happens with basically this kind of code: https://gist.github.com/pierr3/630fc76dd8c987500d8ed7895e46ec59

@Ali-RS
Copy link

Ali-RS commented Nov 7, 2016

I have the similar problem.Mine has nothing to do with Swing but in jMonkeyengine.
I recently update my jme game from lwjgl 2.9.x (which is default by jMonkeyengine) to lwjgl 3.0.0 and now when running game i get

X Error of failed request:  RenderBadPicture (invalid Picture parameter)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  7 (RenderFreePicture)
  Picture id in failed request: 0x2c00023
  Serial number of failed request:  1422
  Current serial number in output stream:  1423
AL lib: (EE) alc_cleanup: 1 device not closed
:run FAILED 

I am on
Lenovo laptop
Ubuntu 16.10
Intel HD 3000 and AMD HD 6370m switchable graphic.

I asked my problem in jme forum but i got no response so decided to ask it here.
Full detail is here :
https://hub.jmonkeyengine.org/t/experimenting-lwjgl3/37275

@Spasi
Copy link
Member

Spasi commented Nov 7, 2016

Could you try with LWJGL 3.1.0?

Can you force your system to use the AMD GPU instead of the Intel HD?

@Ali-RS
Copy link

Ali-RS commented Nov 8, 2016

Could you try with LWJGL 3.1.0?

I tried to build with 3.1.0 by editing build.gradle in jme3-lwjgl3 :

if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

def lwjglVersion = '3.1.0'
def lwjglNativesVersion = '3.0.0'

sourceCompatibility = '1.8'

dependencies {
    compile project(':jme3-core')
    compile project(':jme3-desktop')

    compile "org.lwjgl:lwjgl:${lwjglVersion}"
    compile "org.lwjgl:lwjgl-platform:${lwjglNativesVersion}:natives-windows"
    compile "org.lwjgl:lwjgl-platform:${lwjglNativesVersion}:natives-linux"
    compile "org.lwjgl:lwjgl-platform:${lwjglNativesVersion}:natives-osx"
    compile "org.lwjgl:lwjgl-glfw:${lwjglVersion}"
    compile "org.lwjgl:lwjgl-openal:${lwjglVersion}"
    compile "org.lwjgl:lwjgl-opencl:${lwjglVersion}"
    compile "org.lwjgl:lwjgl-opengl:${lwjglVersion}"
}

but when running game i am getting this error

Executing: gradle :run
Arguments: [-PmainClass=example.Main, -PcmdLineArgs=, -c, /media/idea/01D0ABF282E1DD20/Java/jME_NB-PW-11-6-2015/Examples/sim-eth-es/settings.gradle]

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:assets:compileJava UP-TO-DATE
:assets:processResources UP-TO-DATE
:assets:classes UP-TO-DATE
:assets:jar UP-TO-DATE
:run
SimEthereal Example 2
Setting root JUL log level to:INFO
logger config:root
Setting JUL Log: level to:INFO
logger config:com.simsilica.sim
Setting JUL Log:com.simsilica.sim level to:FINER
logger config:example
Setting JUL Log:example level to:FINE
18:14:01,702 INFO  [JmeSystem] Running on jMonkeyEngine 3.2-1
 * Branch: master
 * Git Hash: c50b4db
 * Build Date: 2016-09-22
18:14:01,860 ERROR [LegacyApplication] Uncaught exception thrown in Thread[main,5,main]
java.lang.ExceptionInInitializerError
    at org.lwjgl.glfw.GLFW.nglfwSetErrorCallback(GLFW.java:794) ~[lwjgl-glfw-3.1.0.jar:?]
    at org.lwjgl.glfw.GLFW.glfwSetErrorCallback(GLFW.java:823) ~[lwjgl-glfw-3.1.0.jar:?]
    at com.jme3.system.lwjgl.LwjglWindow.createContext(LwjglWindow.java:129) ~[jme3-lwjgl3-3.2.0-SNAPSHOT.jar:3.2.0-UNKNOWN]
    at com.jme3.system.lwjgl.LwjglWindow.initInThread(LwjglWindow.java:353) ~[jme3-lwjgl3-3.2.0-SNAPSHOT.jar:3.2.0-UNKNOWN]
    at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:479) ~[jme3-lwjgl3-3.2.0-SNAPSHOT.jar:3.2.0-UNKNOWN]
    at com.jme3.system.lwjgl.LwjglWindow.create(LwjglWindow.java:324) ~[jme3-lwjgl3-3.2.0-SNAPSHOT.jar:3.2.0-UNKNOWN]
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:463) ~[jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424) ~[jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:125) ~[jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
    at example.Main.main(Main.java:107) ~[main/:?]
Caused by: java.lang.IllegalStateException: This function is not available.
    at org.lwjgl.system.Checks.checkFunctionAddress(Checks.java:94) ~[lwjgl-3.1.0.jar:?]
    at org.lwjgl.system.APIUtil.apiGetFunctionAddress(APIUtil.java:120) ~[lwjgl-3.1.0.jar:?]
    at org.lwjgl.glfw.GLFW$Functions.<clinit>(GLFW.java:621) ~[lwjgl-glfw-3.1.0.jar:?]
    ... 10 more
:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/local/jmonkeyplatform/jdk/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 24.616 secs



Build failure (see the Notifications window for stacktrace): gradle :run

Can you force your system to use the AMD GPU instead of the Intel HD?

I forced to use AMD using DRI_PRIME=1 command but Error happens again.
As you see in log below it switched to AMD Renderer: Gallium 0.4 on AMD CEDAR (DRM 2.43.0, LLVM 3.8.0)

Executing: gradle :run
Arguments: [-PmainClass=example.Main, -PcmdLineArgs=, -c, /media/idea/01D0ABF282E1DD20/Java/jME_NB-PW-11-6-2015/Examples/sim-eth-es/settings.gradle]

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:assets:compileJava UP-TO-DATE
:assets:processResources UP-TO-DATE
:assets:classes UP-TO-DATE
:assets:jar UP-TO-DATE
:run
SimEthereal Example 2
Setting root JUL log level to:INFO
logger config:root
Setting JUL Log: level to:INFO
logger config:com.simsilica.sim
Setting JUL Log:com.simsilica.sim level to:FINER
logger config:example
Setting JUL Log:example level to:FINE
18:30:25,057 INFO  [JmeSystem] Running on jMonkeyEngine 3.2-1
 * Branch: master
 * Git Hash: c50b4db
 * Build Date: 2016-09-22
**18:30:25,679 INFO  [LwjglContext] LWJGL 3.0.0 build 90 context running on thread main
 * Graphics Adapter: GLFW 3.2.0 X11 GLX EGL clock_gettime /dev/js Xf86vm shared
18:30:26,015 INFO  [GLRenderer] OpenGL Renderer Information
 * Vendor: X.Org
 * Renderer: Gallium 0.4 on AMD CEDAR (DRM 2.43.0, LLVM 3.8.0)**
 * OpenGL Version: 3.0 Mesa 11.2.0
 * GLSL Version: 1.30
 * Profile: Compatibility
18:30:26,068 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.ogre.MeshLoader
18:30:26,069 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.ogre.SkeletonLoader
18:30:26,070 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.ogre.MaterialLoader
18:30:26,071 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.ogre.SceneLoader
18:30:26,071 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
18:30:26,074 WARN  [AssetConfig] Cannot find loader com.jme3.scene.plugins.fbx.FbxLoader
18:30:26,077 WARN  [AssetConfig] Cannot find loader com.jme3.audio.plugins.OGGLoader
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
18:30:26,219 INFO  [ALAudioRenderer] Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.17.2
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFTX_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_pause_device
 * AL extensions: AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_block_alignment AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length
18:30:26,220 INFO  [ALAudioRenderer] Audio effect extension version: 1.0
18:30:26,226 INFO  [ALAudioRenderer] Audio max auxiliary sends: 4
18:30:26,530 INFO  [GuiGlobals] Initializing GuiGlobals with:com.simsilica.lemur.GuiGlobals@15ca7889
18:30:26,577 INFO  [GuiGlobals] Lemur build date:20161107
18:30:26,579 INFO  [BaseStyles] loadStyleResource(com/simsilica/lemur/style/base/glass-styles.groovy)
18:30:27,549 INFO  [BaseStyles] Loading base resource:jar:file:/home/idea/opt/packages/gradle/gradle-3.0/caches/modules-2/files-2.1/com.github.jMonkeyEngine-Contributions.Lemur/lemur/4493c92a1f/986a10b5b402eb34a8b4a7131a2457374e1cc8f4/lemur-4493c92a1f.jar!/com/simsilica/lemur/style/base/glass-styles.groovy
18:30:28,729 INFO  [BaseStyles] Loading extension resources for:com/simsilica/lemur/style/base/glass-styles.groovy
18:30:28,730 INFO  [BaseStyles] Loading extension resource:jar:file:/home/idea/opt/packages/gradle/gradle-3.0/caches/modules-2/files-2.1/com.github.jMonkeyEngine-Contributions.Lemur/lemur-props/4493c92a1f/dd4fa62d0c0b13608b9752e18c0c04fa49cfd23e/lemur-props-4493c92a1f.jar!/com/simsilica/lemur/style/base/glass-styles.groovy
18:30:28,798 INFO  [BaseStyles] Loading extension resource:jar:file:/home/idea/opt/packages/gradle/gradle-3.0/caches/modules-2/files-2.1/com.github.jMonkeyEngine-Contributions.Lemur/lemur-proto/4493c92a1f/b4c98ff4774f83d85cbd6fefad2c2e42e4680d94/lemur-proto-4493c92a1f.jar!/com/simsilica/lemur/style/base/glass-styles.groovy
18:30:29,108 INFO  [BaseStyles] Loading extension resource:jar:file:/home/idea/opt/packages/gradle/gradle-3.0/caches/modules-2/files-2.1/com.simsilica/lemur/1.8.2/6be7911edec09aca630ebda559f2cfd01ed403f1/lemur-1.8.2.jar!/com/simsilica/lemur/style/base/glass-styles.groovy
X Error of failed request:  RenderBadPicture (invalid Picture parameter)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  7 (RenderFreePicture)
  Picture id in failed request: 0x5600023
  Serial number of failed request:  900
  Current serial number in output stream:  901
AL lib: (EE) alc_cleanup: 1 device not closed
:run FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/local/jmonkeyplatform/jdk/bin/java'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 14.924 secs



Build failure (see the Notifications window for stacktrace): gradle :run

Edit : I also tested on java 9 but the problem happened again.

@Ali-RS
Copy link

Ali-RS commented Nov 8, 2016

Also I tested on Windows and everything works OK in windows using lwjgl 3.0.0.

@Spasi
Copy link
Member

Spasi commented Nov 8, 2016

I tried to build with 3.1.0 by editing build.gradle in jme3-lwjgl3 :
...
but when running game i am getting this error

Updating from LWJGL 3.0.0 to 3.1.0 is not trivial because of the new modular architecture. The error above is likely caused by a mismatch between the Java and native libraries. Try running with -Dorg.lwjgl.util.Debug=true and -Dorg.lwjgl.util.DebugLoader=true to get more information about what's wrong.

I forced to use AMD using DRI_PRIME=1 command but Error happens again.

It will be very hard to diagnose this issue without more details. The simplest thing you could do is try to reproduce the issue with just LWJGL code, not via jME.

@Ali-RS
Copy link

Ali-RS commented Nov 8, 2016

Just found that when i disable Groovy Glass Style on game GUI (which uses groovy-all.jar) that error happens just occasionally and it runs fine most of the time.

The error above is likely caused by a mismatch between the Java and native libraries

What version for natives library matches with lwjgl 3.1.0 then? If i set 3.1.0 for natives it can not find jars for this reason i set 3.0.0.

@Ali-RS
Copy link

Ali-RS commented Nov 8, 2016

What version for natives library matches with lwjgl 3.1.0 then?

Never mind. I can see your new download page do generate gradle snippet automatically. That's very cool.
I will try it, hope it works this time.

@Ali-RS
Copy link

Ali-RS commented Nov 8, 2016

Okay, I could build successfully with 3.1.0. when i ran the game for the first time after build, setting groovy glass style on, it ran like a charm but when i closed and reopened it failed with same error.
But turning off glass style it runs fine.

@Spasi
Copy link
Member

Spasi commented Nov 8, 2016

It sounds like it's a jME or groovy issue then. I have experience with neither, you probably need someone with good knowledge of jME internals to figure out what is going on.

I can only guess and my suspicion lies with threading. Does loading groovy or running groovy scripts require new threads to be spawned? You can check yourself with ctrl+break before and after setting the GUI style.

@Ali-RS
Copy link

Ali-RS commented Dec 24, 2016

@Spasi sorry for late reply ...
I could solve the problem.
Actually it was related to Swing ...
I disabled Settings menu in jME (which is a splash screen with some settings like vsync, screen resolution , antialiasing ,...) which is a swing canvas.
By disabling it, game runs fine.

@Spasi Spasi closed this as completed Dec 24, 2016
@fleather
Copy link

Hey everyone,

I wondered if there is any news on this topic, besides @Ali-RS managed to avoid the problem.
Unfortunately I'm facing the same issue. My setup:

  • Ubuntu 17.10
  • LWJGL 3.1.6

Before the actual game built with OpenGL 3.2 I have a small resolution picker dialog written in Java-Swing. Then after some time the game crashes with the following command line output:

X Error of failed request:  RenderBadPicture (invalid Picture parameter)
  Major opcode of failed request:  139 (RENDER)
  Minor opcode of failed request:  7 (RenderFreePicture)
  Picture id in failed request: 0x4c0001d
  Serial number of failed request:  6928
  Current serial number in output stream:  6931

If I omit the picker dialog and set the resolution hard coded, everything works fine. Is there anything I can do? I didn't have the problem with the same project and LWJGL 2.9.3

Thank you very much for your great work in LWJGL!

@Spasi
Copy link
Member

Spasi commented Mar 11, 2018

The proper fix for this is to not use AWT/Swing for the dialog. The second best choice is to use a different process for the dialog (launch VM -> show dialog -> launch another VM -> run LWJGL application in the new VM). Even if a workaround for the X error is found, using AWT/Swing + GLFW in the same process is simply not possible on macOS. Which is a major issue, unless you only care about Linux/Windows.

For the X error itself, I still think it's an issue with AWT/Swing and not related to GLFW at all. If someone could prepare an MCVE, I'll try to find what's causing it exactly.

Two random things you could try, after discarding the dialog and before calling glfwInit:

  • Run System.gc(), at least two times. Not sure how AWT handles native resources, maybe there's a finalizable/PhantomRef-ed resource that is not released immediately, but a subsequent GC triggers a (too late) free. Actually, could you also run your application with -XX:+PrintGC (or -Xlog:gc on Java 9+) and see if the crash coincides with a GC cycle?
  • Run this snippet:
long display = X11.nXOpenDisplay(NULL);
if (display != NULL) {
    System.out.println("Opened display: " + display);

    try (SharedLibrary libX11 = Library.loadNative("X11")) {
        long XSync = libX11.getFunctionAddress("XSync");
        if (XSync != NULL) {
            System.out.println("Found XSync: " + XSync);

            int ret = JNI.invokePI(XSync, display, 0); // try 1 too if 0 doesn't help
            System.out.println("XSync returned: " + ret);
        }

        X11.XCloseDisplay(display);
    }
}

@fleather
Copy link

Thanks for the quick anwer!

Okay, this means I could replace the resolution picker with a e.g. FX variant?

@Spasi
Copy link
Member

Spasi commented Mar 11, 2018

I don't know about the X error, but JavaFX and GLFW are in the same way incompatible on macOS.

@fleather
Copy link

fleather commented Mar 11, 2018

I see... Is this something which is worked on, or a situation which can't be fixed? I think about the engines and editors (JMonkeyEngine) mixing a UI (Swing/FX) with LWJGL 3.

I migrated my own level editor from Swing to FX first, and then switched from LWJGL 2 to 3. No problems so far, but I didn't run it on a Mac yet.

(my new JavaFX resolution picker doesn't crash the game btw.)

@Spasi
Copy link
Member

Spasi commented Mar 12, 2018

Is this something which is worked on, or a situation which can't be fixed?

It cannot be fixed without modifying JavaFX. We made a decent attempt last year and there's also JFXGL. Now that JavaFX is being removed from the JDK, we'll try to do better soon, see here for more information.

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

No branches or pull requests

7 participants