Help needed with Bombsquad snap

The Bombsquad snap I published has a weird issue I cannot fathom how to solve. It works, but only from the second time you run it. The first time, it always crashes. Second time onward is fine. I have made it unlisted until this is solved. Anyone got any ideas?

Yaml is here.

Here’s first run:

$ snap run bombsquad
update.go:85: cannot change mount namespace according to change mount (/run/user/1000/doc/by-app/snap.bombsquad /run/user/1000/doc none bind,rw,x-snapd.ignore-missing 0 0): cannot inspect "/run/user/1000/doc": lstat /run/user/1000/doc: permission denied
Testing for explicit PulseAudio choice...
...and PulseAudio has been explicitly chosen, so using it.
root: BombSquad 1.7.28 build 21325.
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
FATAL ERROR: No audio devices found. Do you have speakers/headphones/etc. connected?
CPP-STACK-TRACE-BEGIN:
./bombsquad(_ZN10ballistica4core12CorePlatform13GetStackTraceEv+0x4d) [0x561be481822d]
./bombsquad(_ZN10ballistica10FatalError16ReportFatalErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb+0x207) [0x561be49093e7]
./bombsquad(_ZN10ballistica10FatalErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x22) [0x561be49035d2]
./bombsquad(_ZN10ballistica4base11AudioServer18OnAppStartInThreadEv+0x7a0) [0x561be47450d0]
./bombsquad(_ZN10ballistica9EventLoop20RunPendingRunnables_Ev+0x70) [0x561be4904140]
./bombsquad(_ZN10ballistica9EventLoop4Run_Eb+0x158) [0x561be4904ac8]
./bombsquad(_ZN10ballistica9EventLoop11ThreadMain_Ev+0x21f) [0x561be490588f]
./bombsquad(_ZN10ballistica9EventLoop17ThreadMainAudioP_EPv+0xd) [0x561be4905b9d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8609) [0x7f024daf7609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7f024cc8f133]
CPP-STACK-TRACE-END
/snap/bombsquad/x1/bin/launcher: line 4: 881875 Aborted                 (core dumped) ./bombsquad "$@"

Here’s second run, which works fine.

$ snap run bombsquad
update.go:85: cannot change mount namespace according to change mount (/run/user/1000/doc/by-app/snap.bombsquad /run/user/1000/doc none bind,rw,x-snapd.ignore-missing 0 0): cannot inspect "/run/user/1000/doc": lstat /run/user/1000/doc: permission denied
Testing for explicit PulseAudio choice...
...and PulseAudio has been explicitly chosen, so using it.
root: BombSquad 1.7.28 build 21325.
>>> AL lib: (EE) alc_cleanup: 1 device not closed

This is also happening with the sfxr snap. After a clean install, first run always fails, second run works.

@lucyllewy any ideas?

$ sfxr
Testing for explicit PulseAudio choice...
...and PulseAudio has been explicitly chosen, so using it.
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM sysdefault
[!] source/main.cpp:1367  !SDL_OpenAudio(&des, __null)
alan@ziggy:~/Source/popey/sfxr-snap$ sfxr
Testing for explicit PulseAudio choice...
...and PulseAudio has been explicitly chosen, so using it.
alan@ziggy:~/Source/popey/sfxr-snap$ 

Hi Alan,

Anytime I’ve personally used ALSA --> Pulse in snaps, I’ve never personally had to use the full alsa-mixin part provided by Lucy; there might be bits that it handles that I’m unaware of. Personally, I usually do it more directly, like in https://github.com/runelite/snap/blob/master/snap/snapcraft.yaml

Specifically:

  1. Stage

    • libpulse0
    • libasound2
    • libasound2-plugins

(Might not even need libpulse0 if using the desktop extensions).

  1. Add ALSA_CONFIG_PATH as an environment pointing to the file in 3), e.g:
environment: 
  ALSA_CONFIG_PATH: "$SNAP/etc/asound.conf"
  1. Ensure ALSA_CONFIG_PATH exists, in the snap example above we just create it as an override.
override-pull: |
      mkdir etc -p
      cat > etc/asound.conf <<EOF
      pcm.!default {
          type pulse
          fallback "sysdefault"
          hint {
              show on
              description "Default ALSA Output (currently PulseAudio Sound Server)"
          }
      }
      ctl.!default {
          type pulse
          fallback "sysdefault"
      }
      EOF

A lot of this was ripped of Lucy’s mixin part fwiw ;).

Hopefully this might workaround whatevers actually going on.

Thanks for that! Interestingly, it only worked with the gnome extension specified. I’m on core20 with sfxr, and so used gnome-3-38. I did have the various libraries specified in the yaml, even without the extension. Weird. Thanks.