devopvoid / webrtc-java

WebRTC for desktop platforms running Java
Apache License 2.0
248 stars 60 forks source link

linux-ubuntu-18.04 load lib blocked #44

Closed nanguantong closed 2 years ago

nanguantong commented 2 years ago

Hi, when I depoy project with webrtc-java 0.4.0-SNAPSHOT on ubuntu-18.04,runAudioProcessing apm = new AudioProcessing();, and then blocked, why? lack lib path ?

gradle config as following:

buildscript {
    ext {
        webRtcVersion = '0.4.0-SNAPSHOT'
    }
}
implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion"
    if (OperatingSystem.current().isWindows())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:windows-x86_64"
    else if (OperatingSystem.current().isLinux())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:linux-x86_64"
    else if (OperatingSystem.current().isMacOsX())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:macos-x86_64"

then I extract libwebrtc-java.so to /home/ubuntu/ and try System.load("/home/ubuntu/libwebrtc-java.so");, the same blocked,so the lib is incompatible with ubuntu-18.04?

nanguantong commented 2 years ago

So I test the load lib simplely ,as following separately:

class test_load_lib {
    public static void main(String[] args) {
        System.load("/home/ubuntu/libwebrtc-java.so");
    }
}

get the result as following:

Exception in thread "main" java.lang.NoClassDefFoundError: dev/onvoid/webrtc/logging/Logging$Severity
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
    at java.base/java.lang.Runtime.load0(Runtime.java:768)
    at java.base/java.lang.System.load(System.java:1837)
    at test_load_lib.main(test_load_lib.java:6)
Caused by: java.lang.ClassNotFoundException: dev.onvoid.webrtc.logging.Logging$Severity
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    ... 8 more
devopvoid commented 2 years ago

That's because your classpath is missing dev.onvoid.webrtc:webrtc-java:$webRtcVersion. Once you run AudioProcessing apm = new AudioProcessing(); the native library is automatically extracted into the temp folder of your OS. You don't have to do that yourself.

Be aware that IntelliJ IDEA has some issues with maven dependencies that have a classifier, such as dev.onvoid.webrtc:webrtc-java:$webRtcVersion:linux-x86_64, see this issue.

nanguantong commented 2 years ago

Yes, the config has no problem,

implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion"
    //if (OperatingSystem.current().isWindows())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:windows-x86_64"
    //else if (OperatingSystem.current().isLinux())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:linux-x86_64"
    //else if (OperatingSystem.current().isMacOsX())
        implementation "dev.onvoid.webrtc:webrtc-java:$webRtcVersion:macos-x86_64"

but actually once call the new AudioProcessing() on ubuntu-18.04, debug into the code that found the System.load("/tmp/webrtc-java--xxxxx.so"); blocked.

nanguantong commented 2 years ago

So I test the load lib simplely ,as following separately:

class test_load_lib {
    public static void main(String[] args) {
        System.load("/home/ubuntu/libwebrtc-java.so");
    }
}

get the result as following:

Exception in thread "main" java.lang.NoClassDefFoundError: dev/onvoid/webrtc/logging/Logging$Severity
  at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
  at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
  at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
  at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
  at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
  at java.base/java.lang.Runtime.load0(Runtime.java:768)
  at java.base/java.lang.System.load(System.java:1837)
  at test_load_lib.main(test_load_lib.java:6)
Caused by: java.lang.ClassNotFoundException: dev.onvoid.webrtc.logging.Logging$Severity
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
  ... 8 more

I runjava -cp .:/home/ubuntu/code/test/webrtc-java-0.4.0.jar test_load_lib, the same blocked.

class test_load_lib {
    public static void main(String[] args) {
    System.out.print("1");
        System.load("/home/ubuntu/code/test/libwebrtc-java.so");
    System.out.print("2");
    }
}

only print "1", not output "2".

NOTE: no use gradle or maven, directly javac / java.

nanguantong commented 2 years ago

@devopvoid , Please help me try to fix this problem?

devopvoid commented 2 years ago

This is not a bug. It's part of your project setup with Gradle. I don't have time to port this library to the Gradle build system. For reference see here: https://github.com/devopvoid/webrtc-java/issues/23#issuecomment-913850689

nanguantong commented 2 years ago

This is not a bug. It's part of your project setup with Gradle. I don't have time to port this library to the Gradle build system. For reference see here: https://github.com/devopvoid/webrtc-java/issues/23#issuecomment-913850689

Not use gradle,directly extract so from jar to dir then System.Load(/xxx/libwebrtc_java.so),you can try it on ubuntu18.04

nanguantong commented 2 years ago

This is not a bug. It's part of your project setup with Gradle. I don't have time to port this library to the Gradle build system. For reference see here: #23 (comment)

Not use gradle,directly extract so from jar to dir then System.Load(/xxx/libwebrtc_java.so),you can try it on ubuntu18.04

Then I port this call to other ubuntu-18.04 (with desktop gtk ui) that run ok,then put th second ubuntu-18.04 (without desktop) that run also blocked , that's weird ...

nanguantong commented 2 years ago

This is not a bug. It's part of your project setup with Gradle. I don't have time to port this library to the Gradle build system. For reference see here: #23 (comment)

Not use gradle,directly extract so from jar to dir then System.Load(/xxx/libwebrtc_java.so),you can try it on ubuntu18.04

Then I port this call to other ubuntu-18.04 (with desktop gtk ui) that run ok,then put th second ubuntu-18.04 (without desktop) that run also blocked , that's weird ...

Finally, I found this stuck problem that must apt install pulseaudio (/usr/bin/pulseaudio), not only install libpulse-dev / libpulse0.

image

NOTE: And pulseaudio don't run with root, or the same blocked ....

nanguantong commented 2 years ago

Do you please remove libpulse and libX11 deps from webrtc?

devopvoid commented 2 years ago

This library is not linked against libX11. WebRTC links libpulse as well.

With the recent commit webrtc-java should load.