[SOLVED] Using core18 and multipass issues with sound and build


#1

This version of my snapcraft.yaml snaps and runs fine when built in a 16.04 LXD container: https://github.com/jsseidel/jgalaxian/blob/master/snap/snapcraft.yaml

Today, I wanted to add a simple feature and decided to take the opportunity to try and get it building in my local bionic environment (snap install snapcraft --classic, snap install --beta multipass --classic). I therefore added base: core18 to snapcraft.yaml.

The build worked, but I had no pulseaudio sound. I searched the forum and discovered that I might need to add ‘libpulse0’ to my staged-packages. Still no sound (and no errors). I tried adding a desktop environment so that I could launch it with desktop-launch, in the unlikely event I needed a codec from gstreamer or something. Still no sound (and no errors).

I then removed base: core18 and tried building in my 18.04 environment. It fails. Here’s a bit of relevant output:

Priming jgalaxian
The linker version '2.23' used by the base 'core' is incompatible with files in this snap:
    /home/jsseidel/PersonalWorkspace/git/jgalaxian/prime/lib/x86_64-linux-gnu/libbsd.so.0.8.7 (2.25)

I had assumed that removing base: core18 would make snapcraft build in a 16.04 multipass VM. This is obviously not what happens, so fine. But can you see why this is confusing? When I have base: core18 specified, snapcraft builds in a multipass VM even tho I’m running snapcraft in bionic. When I remove that, presumably to enable a 16.04 core, snapcraft tries to link against newer bionic libraries (I guess). I’ve probably made a bad assumption here (or, more likely, several bad assumptions).

So 2 questions:

What do I need to get pulseaudio sound working in core18?

Why doesn’t the build work at all when running snapcraft in a bionic enviroment without core18 specified in snapcraft.yaml?

Thanks as always for the info!


#2

Tried upgrading to jdk11, but still no pulseaudio under core18. The only way I can get pulseaudio working for a java app is by using snapcraft in a 16.04 VM.

A sample run that shows that stuff is seemingly in the right places:

$ snap run jgalaxian
LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/jgalaxian/x1/usr/lib/x86_64-linux-gnu/pulseaudio:/snap/jgalaxian/x1/lib:/snap/jgalaxian/x1/usr/lib:/snap/jgalaxian/x1/lib/x86_64-linux-gnu:/snap/jgalaxian/x1/usr/lib/x86_64-linux-gnu
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.3)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.3, mixed mode)
$ ls -l /snap/jgalaxian/x1/usr/lib/x86_64-linux-gnu/pulseaudio
total 503
-rw-r--r-- 1 root root 514216 Jan 23 01:54 libpulsecommon-11.1.so
$

This is my snapcraft.yaml, which should snap out of the box (except for the gui launching stuff, of course) using snap multipass/snapcraft or apt installed snapcraft in Bionic:

name: jgalaxian
version: "0.0.1"
summary: A Java Galaxian clone
description: |
  JGalaxian is a Java-based Galaxian clone.
confinement: strict
grade: stable
base: core18

apps:
  jgalaxian:
    command: bash -c "echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ; java -version ; java -Djava.util.prefs.userRoot=\"$SNAP_USER_DATA\" -jar $SNAP/jar/jgalaxian-1.0-SNAPSHOT.jar"
    environment:
      JAVA_HOME: ${SNAP}/usr/lib/jvm/java-11-openjdk-amd64
      PATH: ${JAVA_HOME}/jre/bin:${PATH}
      # pulseaudio
      LD_LIBRARY_PATH: ${SNAP}/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
      # Needed for fontconfig
      XDG_DATA_HOME: ${SNAP}/usr/share
      FONTCONFIG_PATH: ${SNAP}/etc/fonts/config.d
      FONTCONFIG_FILE: ${SNAP}/etc/fonts/fonts.conf
    plugs: [x11,pulseaudio]

parts:
  jgalaxian:
    plugin: maven
    source-type: git
    source: https://github.com/jsseidel/jgalaxian
    source-branch: jdk11
    build-packages:
      - openjdk-11-jdk
    stage-packages:
      - libpulse0
      - libpulse-java

Source: https://github.com/jsseidel/snaps/tree/master/jgalaxian/snap

I thought it contains the 3 necessary ingredients for pulseaudo: LD_LIBRARY_PATH, libpulse0, and the pulseaudio plug. But still no sound :frowning:


#3

One more clue that makes me think this is more like a snapd/snapcraft bug than anything else.

The snap install has no sound in Disco, but it does in Bionic. When built and run on Disco from source, sound works.

Should I report this as a bug in Launchpad?


#4

To build on a 16.04 environment, use base: core in snapcraft.yaml.


#5

Ah, great. Thanks, @sergiusens. I can build a working 16.04 snap via multipass with base: core. Probably I missed that in the docs.

So to summarize my builds:

(1) base: core: has sound, everything works as expected.
(2) base: core18: no sound, no clue why
(3) base: core: working in 18.04, when installed in Disco, no sound

I think (2) and (3) might be worth me reporting as bugs on launchpad?


#6

I had a similar problem which I solved by following the advice in https://github.com/diddledan/snapcraft-alsa. I also found it was necessary to remove libpulse0 from my stage packages.


#7

Oh, good find. I will play with that and post any progress. Thanks, @songbuilder!


#8

Oh, forgot to ask. @songbuilder, have you tried running your working snap in 19.04 (disco)?


#9

No, just 18.04. I tend to stick to the LTS releases. I am hoping to publish my snap to the Snap store within the next few days as “audovia-classic”.


#10

It’s a cool snap, btw – I checked it out while trying to solve my own issues. Long ago, I used to be a musician (guitar), so I thought it was interesting. Good to see that kind of thing on linux, too.


#11

@songbuilder, alas, none of the alsa stuff worked for me :frowning:


#12

Can you publish your snapcraft.yaml file here. Hopefully, someone will be able to help.


#13

I’ve made so many different iterations to try and make it work in core18, I wouldn’t know which new one to post. Since I can for now just use 16.04 and everything works, I’m going to stick to that. I don’t yet have an incentive to change. I just wanted to see if I could get it to work in core18.

I figure by the time I’m forced to upgrade, they’ll have fixed many of the bugs that might be causing this.


#14

Finally figured the silly thing out. This snapcraft.yaml works with sound, built with the snap versions of snapcraft and multipass using core18:

name: jgalaxian
version: "0.0.1"
summary: A Java Galaxian clone
description: |
  JGalaxian is a Java-based Galaxian clone.
confinement: strict
grade: stable
base: core18

apps:
  jgalaxian:
    command: bash -c "${SNAP}/usr/lib/jvm/java-8-openjdk-${SNAP_ARCH}/bin/java -version ; ${SNAP}/usr/lib/jvm/java-8-openjdk-${SNAP_ARCH}/bin/java -Djava.util.prefs.userRoot=\"$SNAP_USER_DATA\" -jar $SNAP/jar/jgalaxian-1.0-SNAPSHOT.jar $*"
    environment:
      # pulseaudio
      LD_LIBRARY_PATH: ${SNAP}/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio
      # Needed for fontconfig
      XDG_DATA_HOME: ${SNAP}/usr/share
      FONTCONFIG_PATH: ${SNAP}/etc/fonts/config.d
      FONTCONFIG_FILE: ${SNAP}/etc/fonts/fonts.conf
    plugs: [x11,pulseaudio]

parts:
  jgalaxian:
    plugin: maven
    source-type: local
    source: .
    build-packages:
      - openjdk-8-jdk
    stage-packages:
      - openjdk-8-jdk
      - libpulse0

The issue I think I was running into had more to do with how apt and java work than snapcraft. Apt installs an 11 jdk (probably because of the maven plugin, I’m guessing), and I wasn’t specifying which java to use specifically, so java was picking up 11 instead of 8. There are issues with sound in 11 I wasn’t aware of, so I had to be more careful about which version of java to use both for compilation and for runtime inside the snap.

The only small issue left is that something in the java AWT framework is trying to run “/usr/bin/xprop” here:

at org.GNOME.Accessibility.AtkWrapper.<clinit>(AtkWrapper.java:37)

But it doesn’t seem to affect how the game runs, so I’m ignoring it.