regal
May 17, 2024, 8:07am
1
Hi,
When I start a core22 based snap app running on openjdk-21-jre, the following line gets logged to the console:
Could not load native libraries for ScreencastHelper
and the screen capturing fails (just captures a black screen).
plugs:
[home, network, desktop, wayland]
...
stage-packages:
[openjdk-21-jre, pipewire]
If I build it locally with snapcraft prime --shell
and then execute ../stage/usr/bin/pipewire --version
I get the following error:
…/stage/usr/bin/pipewire: error while loading shared libraries:
libpipewire-0.3.so.0: cannot open shared object file: No such file or directory
(adding libpipewire-0.3-0
to the stage-packages
didn’t help)
It looks like snap support will just be added in the upcoming 1.2 release of pipewire: https://gitlab.freedesktop.org/pipewire/pipewire/-/releases/1.1.81
Which leads me to the following burning questions:
Will pipewire 1.2 ever be available in core22
?
If not, when will the gnome
extension be available for core24
?
As Wayland is the default display manger in 24.04, this issue is getting more and more urgent, probably not only for my Java based remote desktop snap.
By the way, I don’t intend to spam the forum, I just couldn’t change the the category from other
to snapcraft
on the original topic .
1 Like
regal
May 25, 2024, 11:56am
2
Follow-up: An experimental build with core24 led to the following error:
'this->recurse > 0' failed at ../src/pipewire/thread-loop.c:63 do_unlock()
Therefore, pipewire will most likely not be usable in Snaps until it is updated to version 1.2.
regal
May 25, 2024, 12:46pm
4
@soumyaDghosh I tried that (with core22) - but exactly the same line gets logged to the console:
Could not load native libraries for ScreencastHelper
Can you share your manifest?
regal
May 25, 2024, 12:59pm
6
name: dayon
title: Dayon!
adopt-info: dayon
summary: An easy-to-use, cross-platform remote desktop assistance solution
description: ...
license: GPL-3.0
grade: stable
base: core22
confinement: strict
architectures:
- build-on: [amd64]
build-for: [amd64]
- build-on: [arm64]
build-for: [arm64]
- build-on: [armhf]
build-for: [armhf]
- build-on: [riscv64]
build-for: [riscv64]
lint:
ignore:
- library:
- usr/lib/jvm/java-*/lib/*.so
apps:
assisted:
extensions:
[gnome]
environment:
JAVA_HOME: $SNAP/usr/lib/jvm/java-21-openjdk-$SNAP_ARCH
PATH: $JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
PIPEWIRE_CONFIG_DIR: $SNAP/usr/share/pipewire
PIPEWIRE_MODULE_DIR: $SNAP/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/pipewire-0.3
SPA_PLUGIN_DIR: $SNAP/usr/lib/$SNAP_LAUNCHER_ARCH_TRIPLET/spa-0.2
command: bin/dayon.launcher $SNAP/jar/dayon.jar $1 $2 $3 $4 $5
desktop: ../parts/dayon/build/target/dayon.assisted.desktop
plugs:
[home, network, desktop]
assistant:
extensions:
[gnome]
environment:
JAVA_HOME: $SNAP/usr/lib/jvm/java-21-openjdk-$SNAP_ARCH
PATH: $JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
command: bin/dayon.launcher $SNAP/jar/dayon.jar assistant $1 $2 $3
desktop: ../parts/dayon/build/target/dayon.assistant.desktop
plugs:
[home, network, desktop]
browser:
extensions:
[gnome]
command: bin/dayon.browser
plugs:
[home, network, desktop]
parts:
dayon:
plugin: maven
source: https://github.com/retgal/dayon.git
source-tag: master
source-type: git
maven-parameters:
[-Psnap]
override-pull: |
craftctl default
craftctl set version=$(git describe --tags | sed 's/^v//' | cut -d "-" -f1)
build-packages:
[openjdk-21-jdk, maven]
override-build: |
craftctl default
cp target/dayon.browser $CRAFT_PART_INSTALL/bin/
cp target/dayon.launcher $CRAFT_PART_INSTALL/bin/
cp target/dayon.png $CRAFT_PART_INSTALL/bin/
rm $CRAFT_PART_INSTALL/jar/original-dayon.jar
rm $CRAFT_PART_INSTALL/jar/WaifUPnP-*.jar
rm $CRAFT_PART_INSTALL/jar/xz-*.jar
stage-packages:
[openjdk-21-jre, pipewire]
override-prime: |
craftctl default
rm -r usr/share/doc
rm -r usr/share/man
It’s just the assisted part that needs to enable the screen sharing using pipewire.
So how to run this snap? Just using dayon right?
regal
May 25, 2024, 1:03pm
8
dayon.assisted
for the assisted side or dayon.assistant
for the assistant side
I ran both assistant and assisted snap individually and I got no error showing could not load native libraries. Can you guide how to reproduce the error?
regal
May 25, 2024, 1:38pm
10
The error gets logged, as soon as the assistant accepts the connection from the assisted (this is when the dialog for sharing the screen would be displayed)
To reproduce:
dayon.assisted
dayon.assistant
click the “play” button (top left) on the assistant UI
click the “play” button (top left) on the assisted UI, OK
accept the incomming connection on the assistant UI
the error gets logged into the terminal in which dayon.assisted was started
Prequisite: desktop runs on Wayland - no Wayland > no Pipewire > no problem
Okay, now I got it. How are you trying to use pipewire? Via portals? Also, can you show me that part of the code that produces this error.
regal
May 25, 2024, 2:10pm
12
I’m not using pipewire directly. The JVM (openJDK) just uses pipewire/screencast to capture the screen if its running on Wayland.
So the actual code part probably isn’t very helpful:
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
stream(environment.getScreenDevices()).flatMap(gd -> stream(gd.getConfigurations())).forEach(graphicsConfiguration -> Rectangle2D.union(fullSize, graphicsConfiguration.getBounds(), fullSize));
return fullSize.getBounds();
}
public static byte[] captureGray(Gray8Bits quantization) {
return rgbToGray8(quantization, captureRGB(sharedScreenSize));
}
private static int[] captureRGB(Rectangle bounds) {
BufferedImage image = ROBOT.createScreenCapture(bounds);
int imageHeight = image.getHeight();
int imageWidth = image.getWidth();
if (imageHeight != bounds.height || imageWidth != bounds.width) {
Log.warn(format("Image dimensions %sx%s != bound dimensions %sx%s", imageHeight, imageWidth, bounds.height, bounds.width));
imageHeight = min(image.getHeight(), bounds.height);
imageWidth = min(image.getWidth(), bounds.width);
}
int i = 0;
for (int yPos = bounds.y; yPos < imageHeight; yPos++) {
for (int xPos = bounds.x; xPos < imageWidth && i < rgb.length; xPos++) {
Can you somehow increase the logging? Like which library it didn’t found and all?
regal
May 25, 2024, 3:08pm
14
I increased the log level of the JVM to trace, but no luck - maybe the message comes directly from pipewire?
Pipewire doesn’t really have a loggin like this
Could not load native libraries for ScreencastHelper
How does it know what a ScreencastHelper is? Is your app working fine as a deb? Can you follow the code execution there and which library is it loading. Probably your app searches pipewire in some hardcoded paths.
regal
May 25, 2024, 7:09pm
16
Yes, it works as intended as deb.
Using strace
I couldn’t discover anything, but I got the JVMs library paths:
For the deb :
java.library.path: /usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
(this is with pipewire Compiled with libpipewire 0.3.65)
For the snap :
java.library.path: /var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/dayon/x6/lib:/snap/dayon/x6/usr/lib:/snap/dayon/x6/usr/lib/x86_64-linux-gnu:/snap/dayon/x6/gnome-platform/lib/x86_64-linux-gnu:/snap/dayon/x6/gnome-platform/usr/lib/x86_64-linux-gnu:/snap/dayon/x6/gnome-platform/usr/lib:/snap/dayon/x6/gnome-platform/lib:/snap/dayon/x6/gnome-platform/usr/lib/x86_64-linux-gnu/dri:/var/lib/snapd/lib/gl:/snap/dayon/x6/gnome-platform/usr/lib/x86_64-linux-gnu/libunity:/snap/dayon/x6/gnome-platform/usr/lib/x86_64-linux-gnu/pulseaudio:/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
Does Snapcraft linter show you something suspicious, about rpath for example? If so, try adding those 2 lines:
build-attributes:
- enable-patchelf
If have no idea if that will help, but wouldn’t hurt
Also, try running snap using snappy-debug with snap installed in devmode.
regal
May 25, 2024, 8:31pm
18
Nope, nothing suspicious from the linter, besides some unused lilbraries:
Lint warnings:
- library: libGL.so.1: unused library 'usr/lib/x86_64-linux-gnu/libGL.so.1.7.0'. (https://snapcraft.io/docs/linters-library)
- library: libGLX_mesa.so.0: unused library 'usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0'. (https://snapcraft.io/docs/linters-library)
- library: libXtst.so.6: unused library 'usr/lib/x86_64-linux-gnu/libXtst.so.6.1.0'. (https://snapcraft.io/docs/linters-library)
- library: libgif.so.7: unused library 'usr/lib/x86_64-linux-gnu/libgif.so.7.1.0'. (https://snapcraft.io/docs/linters-library)
- library: libicuio.so.70: unused library 'usr/lib/x86_64-linux-gnu/libicuio.so.70.1'. (https://snapcraft.io/docs/linters-library)
- library: libicutest.so.70: unused library 'usr/lib/x86_64-linux-gnu/libicutest.so.70.1'. (https://snapcraft.io/docs/linters-library)
- library: liblcms2.so.2: unused library 'usr/lib/x86_64-linux-gnu/liblcms2.so.2.0.12'. (https://snapcraft.io/docs/linters-library)
- library: libpulse-simple.so.0: unused library 'usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.1.1'. (https://snapcraft.io/docs/linters-library)
- library: libsmime3.so: unused library 'usr/lib/x86_64-linux-gnu/libsmime3.so'. (https://snapcraft.io/docs/linters-library)
- library: libssl3.so: unused library 'usr/lib/x86_64-linux-gnu/libssl3.so'. (https://snapcraft.io/docs/linters-library)
And snappy-debug only gave me two violations - once for reading some IPV6 interfaces and once a failed attempt to create some font directory:
= AppArmor =
Time: Mai 25 22:12:47
Log: apparmor="DENIED" operation="open" profile="snap.dayon.assisted" name="/proc/109144/net/if_inet6" pid=109144 comm="AWT-EventQueue-" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
= AppArmor =
Time: Mai 25 22:12:47
Log: apparmor="DENIED" operation="mkdir" profile="snap.dayon.assisted" name="/home/snafu/.java/fonts/21.0.2/" pid=109144 comm="AWT-EventQueue-" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
Does this app work now when installed in devmode? How does this app communicate with pipewire? For me it seems plausible that AWT-EventQueue might be suspicious…
regal
May 25, 2024, 8:53pm
20
After installing it via sudo snap install dayon_14.0.1_amd64.snap --dangerous --devmode
all the AppArmor logs contain “ALLOWED”, but still this message of unknown origin in the console:
Could not load native libraries for ScreencastHelper
Thus, no dialog for sharing the screen
libpipewire-0.3.so.0
appears to be where it’s supposed to be:
snap run --shell dayon.assisted
ldd $SNAP/usr/lib/x86_64-linux-gnu/libpipewire-0.3.so.0
linux-vdso.so.1 (0x00007fffba5c4000)
/snap/dayon/x10/gnome-platform/$LIB/bindtextdomain.so => /snap/dayon/x10/gnome-platform/lib/x86_64-linux-gnu/bindtextdomain.so (0x00007f8c8fde7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8c8fba6000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8c8fec6000)