Setting audio renderer to null results in a failure to load lwjgl native library

Using appsettings to set the audio renderer to null as in

  AppSettings appSettings = new AppSettings(true);
  appSettings.setCustomRenderer(AwtPanelsContext.class);
  appSettings.setAudioRenderer(null);

results in the following exception
Exception in thread “LWJGL Renderer Thread” java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.(Sys.java:112)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:148)
at java.lang.Thread.run(Thread.java:722)

Seems you don’t have lwjgl on the classpath, do you use the SDK? Else check the wiki for the meaning of each jar, its under “source structure”.

We’re using the jar files and not the SDK. However, my applications work fine except when i do appsettings.setAudioRenderer(null). For some reason, setting the audio renderer to null results in a failure to load the lwjgl libraries.

I think the problem is in extractNativeLibs in combination with using the AwtPanelsContext. In Natives.extractNativeLibs(Platform, AppSettings) the code to check which libraries to extract is

[java]if (renderer != null) {
if (renderer.startsWith(“LWJGL”)) {
needLWJGL = true;
}
}
if (audioRenderer != null) {
if (audioRenderer.equals(“LWJGL”)) {
needLWJGL = true;
needOAL = true;
}
} [/java]

We have set the renderer to AwtPanelsContext.class, failing the renderer.startsWith(“LWJGL”) test. This means that setting the audioRenderer to null will result in not extracting the native libraries. Changing

[java]
AppSettings appSettings = new AppSettings(true);
appSettings.setCustomRenderer(AwtPanelsContext.class);
appSettings.setAudioRenderer(null);
[/java]

to

[java]
AppSettings appSettings = new AppSettings(true);
appSettings.setCustomRenderer(AwtPanelsContext.class);
try
{
Natives.extractNativeLibs(JmeSystem.getPlatform(), appSettings);
}
catch (IOException e)
{
throw new RuntimeException(“Cannot load native libs”);
}
appSettings.setAudioRenderer(null);
[/java]

results in a working renderer. We want to disable the audio renderer because we don’t use it and it fails to close properly on some platforms. I think the solution is to make the Natives.extractNativeLibs have a more robust check ( quick fix would be to do renderer.startsWith(“LWJGL”) || renderer.startsWith(“CUSTOMAwtPanelsContext”), but that would not be robust for other contexts)

1 Like

Ok, thanks. Funny enough, I am about to rework the renderer and natives extraction code soon anyway, so there won’t be a need for workarounds in the engine :slight_smile: