<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>210101</bug_id>
          
          <creation_ts>2020-04-07 02:23:06 -0700</creation_ts>
          <short_desc>[GTK][Stable] When using wayland webkit wants to take over the alsa device</short_desc>
          <delta_ts>2020-07-05 22:42:37 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Haelwenn (lanodan) Monnier">contact+bugs.webkit.org</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>pnormand</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1638490</commentid>
    <comment_count>0</comment_count>
    <who name="Haelwenn (lanodan) Monnier">contact+bugs.webkit.org</who>
    <bug_when>2020-04-07 02:23:06 -0700</bug_when>
    <thetext>Setup:
- ALSA (with OSS compatibility) no asound.conf
- Wayland compositor: sway (happens in other wlroots-based ones)

I haven&apos;t tested in other setups, the WebKitGTK browser is irrelevant, I also have this issue in MiniBrowser. There is also another issue with graphics but no idea what&apos;s wrong in it and could be an Xwayland issue (as it works fine in pure X11).

I get the following behaviour:

## When something is already using the soundcard

$ GST_DEBUG=*:3 badwolf https://hacktivis.me/kopimi/videos/talks%26confs/Internet%20is%20Coming/internet-is-coming-1.mp4
Running Badwolf version: 0.5.1+gf35b0b8
Buildtime WebKit version: 2.28.0
Runtime WebKit version: 2.28.0
webkit-web-extension directory set to: /home/haelwenn/.local/share/badwolf/webkit-web-extension

** (badwolf:10327): WARNING **: 10:59:52.728: GApplication is required for xdg-desktop-portal access in the WebKit sandbox. Actions that require xdg-desktop-portal will be broken.
0:00:00.020510525     2      0x10f40a0 WARN     GST_ELEMENT_FACTORY gstelementfactory.c:462:gst_element_factory_make: no such element factory &quot;fdkaacdec&quot;!
0:00:00.804653237     2 0x7f93340401e0 WARN                    alsa conf.c:4972:parse_args: alsalib error: Unknown parameter AES0
0:00:00.804699143     2 0x7f93340401e0 WARN                    alsa conf.c:5132:snd_config_expand: alsalib error: Parse arguments error: No such file or directory
0:00:00.804714632     2 0x7f93340401e0 WARN                    alsa pcm.c:2642:snd_pcm_open_noupdate: alsalib error: Unknown PCM default:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02}
0:00:00.814366361     2 0x7f93340401e0 WARN                glwindow gstglwindow.c:288:gst_gl_window_new: Could not create window. user specified (null), creating dummy window
0:00:01.566806585     2 0x7f931c133000 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 1
0:00:01.568251810     2 0x7f931c133000 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 2
0:00:01.821981602     2      0x10f40a0 FIXME                    bin gstbin.c:4349:gst_bin_query: implement duration caching in GstBin again

Result ⇒ no sound

$ GDK_BACKEND=x11 GST_DEBUG=*:3 badwolf https://hacktivis.me/kopimi/videos/talks%26confs/Internet%20is%20Coming/internet-is-coming-1.mp4
Running Badwolf version: 0.5.1+gf35b0b8
Buildtime WebKit version: 2.28.0
Runtime WebKit version: 2.28.0
webkit-web-extension directory set to: /home/haelwenn/.local/share/badwolf/webkit-web-extension

** (badwolf:14125): WARNING **: 11:13:25.293: GApplication is required for xdg-desktop-portal access in the WebKit sandbox. Actions that require xdg-desktop-portal will be broken.
0:00:00.020024943     2      0x1529360 WARN     GST_ELEMENT_FACTORY gstelementfactory.c:462:gst_element_factory_make: no such element factory &quot;fdkaacdec&quot;!
0:00:00.729785910     2 0x7f338403f8a0 WARN                    alsa conf.c:4972:parse_args: alsalib error: Unknown parameter AES0
0:00:00.729817660     2 0x7f338403f8a0 WARN                    alsa conf.c:5132:snd_config_expand: alsalib error: Parse arguments error: No such file or directory
0:00:00.729830604     2 0x7f338403f8a0 WARN                    alsa pcm.c:2642:snd_pcm_open_noupdate: alsalib error: Unknown PCM default:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02}
0:00:01.573696944     2 0x7f3328134280 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 1
0:00:01.575109348     2 0x7f3328134280 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 2
0:00:01.823436788     2      0x1529360 FIXME                    bin gstbin.c:4349:gst_bin_query: implement duration caching in GstBin again

Result ⇒ sound (but no graphics)


## When nothing is using the sound card

$ GST_DEBUG=*:3 badwolf https://hacktivis.me/kopimi/videos/talks%26confs/Internet%20is%20Coming/internet-is-coming-1.mp4
Running Badwolf version: 0.5.1+gf35b0b8
Buildtime WebKit version: 2.28.0
Runtime WebKit version: 2.28.0
webkit-web-extension directory set to: /home/haelwenn/.local/share/badwolf/webkit-web-extension

** (badwolf:15040): WARNING **: 11:16:45.342: GApplication is required for xdg-desktop-portal access in the WebKit sandbox. Actions that require xdg-desktop-portal will be broken.
0:00:00.017133729     2       0xee6410 WARN     GST_ELEMENT_FACTORY gstelementfactory.c:462:gst_element_factory_make: no such element factory &quot;fdkaacdec&quot;!
0:00:00.563284104     2      0x13b35e0 WARN                    alsa conf.c:4972:parse_args: alsalib error: Unknown parameter AES0
0:00:00.563332165     2      0x13b35e0 WARN                    alsa conf.c:5132:snd_config_expand: alsalib error: Parse arguments error: No such file or directory
0:00:00.563351080     2      0x13b35e0 WARN                    alsa pcm.c:2642:snd_pcm_open_noupdate: alsalib error: Unknown PCM default:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02}
0:00:00.573912688     2      0x13b35e0 WARN                glwindow gstglwindow.c:288:gst_gl_window_new: Could not create window. user specified (null), creating dummy window
0:00:01.300522239     2 0x7f8994138c00 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 1
0:00:01.302049328     2 0x7f8994138c00 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 2
0:00:01.543702775     2       0xee6410 FIXME                    bin gstbin.c:4349:gst_bin_query: implement duration caching in GstBin again

Result ⇒ sound (and graphics)

$ GDK_BACKEND=x11 GST_DEBUG=*:3 badwolf https://hacktivis.me/kopimi/videos/talks%26confs/Internet%20is%20Coming/internet-is-coming-1.mp4
Running Badwolf version: 0.5.1+gf35b0b8
Buildtime WebKit version: 2.28.0
Runtime WebKit version: 2.28.0
webkit-web-extension directory set to: /home/haelwenn/.local/share/badwolf/webkit-web-extension

** (badwolf:15411): WARNING **: 11:17:33.015: GApplication is required for xdg-desktop-portal access in the WebKit sandbox. Actions that require xdg-desktop-portal will be broken.
0:00:00.021947285     2      0x1aab760 WARN     GST_ELEMENT_FACTORY gstelementfactory.c:462:gst_element_factory_make: no such element factory &quot;fdkaacdec&quot;!
0:00:00.681498803     2 0x7f62b803f4a0 WARN                    alsa conf.c:4972:parse_args: alsalib error: Unknown parameter AES0
0:00:00.681531816     2 0x7f62b803f4a0 WARN                    alsa conf.c:5132:snd_config_expand: alsalib error: Parse arguments error: No such file or directory
0:00:00.681542846     2 0x7f62b803f4a0 WARN                    alsa pcm.c:2642:snd_pcm_open_noupdate: alsalib error: Unknown PCM default:{AES0 0x02 AES1 0x82 AES2 0x00 AES3 0x02}
0:00:01.457733394     2 0x7f6254133680 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 1
0:00:01.459187487     2 0x7f6254133680 WARN                 qtdemux qtdemux.c:3237:qtdemux_parse_trex:&lt;qtdemux0&gt; failed to find fragment defaults for stream 2
0:00:01.684510874     2      0x1aab760 FIXME                    bin gstbin.c:4349:gst_bin_query: implement duration caching in GstBin again

Result ⇒ sound (but no graphics)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1638496</commentid>
    <comment_count>1</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-04-07 04:01:02 -0700</bug_when>
    <thetext>These issues don&apos;t happen when you use gst-play-1.0 ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1638539</commentid>
    <comment_count>2</comment_count>
    <who name="Haelwenn (lanodan) Monnier">contact+bugs.webkit.org</who>
    <bug_when>2020-04-07 08:08:25 -0700</bug_when>
    <thetext>(In reply to Philippe Normand from comment #1)
&gt; These issues don&apos;t happen when you use gst-play-1.0 ?

Yeah, they&apos;re specific to webkit as far as I can tell.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1638597</commentid>
    <comment_count>3</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-04-07 09:53:50 -0700</bug_when>
    <thetext>I don&apos;t understand... In WebKit we don&apos;t have any specific audio sink yet.

Relying directly on ALSA is a bit old-school. Any chance you could switch to... Pulseaudio?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1638645</commentid>
    <comment_count>4</comment_count>
    <who name="Haelwenn (lanodan) Monnier">contact+bugs.webkit.org</who>
    <bug_when>2020-04-07 10:58:03 -0700</bug_when>
    <thetext>(In reply to Philippe Normand from comment #3)
&gt; I don&apos;t understand... In WebKit we don&apos;t have any specific audio sink yet.
&gt; 
&gt; Relying directly on ALSA is a bit old-school. Any chance you could switch
&gt; to... Pulseaudio?

Nah, in my experiences pulseaudio has been a major pain in the last ten years, from general stability issues to a configuration so large you can end up without sound for a number of reasons that only seems to grow over the years.
ALSA has occasional issues like this one but they can be (hot)fixed quite quickly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1639010</commentid>
    <comment_count>5</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-04-08 05:15:26 -0700</bug_when>
    <thetext>Cool. If you want to debug this, you&apos;re welcome to.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1668974</commentid>
    <comment_count>6</comment_count>
    <who name="Haelwenn (lanodan) Monnier">contact+bugs.webkit.org</who>
    <bug_when>2020-07-05 22:42:37 -0700</bug_when>
    <thetext>I found a fix to make it work.

The reason is from the usage of `--unshare-ipc` in the bubblewrap sandbox when wayland is used which I tried at first with these two commands:

$ bwrap  --proc /proc --dev /dev --ro-bind $PWD/theday.wav{,} --ro-bind /lib64{,} --ro-bind /bin{,} --ro-bind /usr{,} --ro-bind /etc/asound.conf{,} --dev-bind /dev/dsp{,} --dev-bind-try /dev/snd/{,} --ro-bind /etc{,} --unshare-ipc aplay theday.wav
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.2.2-r1/work/alsa-lib-1.2.2/src/pcm/pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
aplay: main:830: audio open error: Device or resource busy
$ bwrap  --proc /proc --dev /dev --ro-bind $PWD/theday.wav{,} --ro-bind /lib64{,} --ro-bind /bin{,} --ro-bind /usr{,} --ro-bind /etc/asound.conf{,} --dev-bind /dev/dsp{,} --dev-bind-try /dev/snd/{,} --ro-bind /etc{,} aplay theday.wav
Playing WAVE &apos;theday.wav&apos; : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo



And I tested it against WebKitGTK with applying the following patch:

diff --git a/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp b/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
--- a/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
+++ b/Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
@@ -797,7 +797,7 @@ GRefPtr&lt;GSubprocess&gt; bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces
 #if PLATFORM(WAYLAND) &amp;&amp; USE(EGL)
         if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) {
             bindWayland(sandboxArgs);
-            sandboxArgs.append(&quot;--unshare-ipc&quot;);
+            //sandboxArgs.append(&quot;--unshare-ipc&quot;);
         } else
 #endif
             bindX11(sandboxArgs);</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>