NetBSD Problem Report #54177

From www@netbsd.org  Wed May  8 15:55:54 2019
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id CF5EF7A186
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  8 May 2019 15:55:53 +0000 (UTC)
Message-Id: <20190508155552.C4BAD7A1CF@mollari.NetBSD.org>
Date: Wed,  8 May 2019 15:55:52 +0000 (UTC)
From: coypu@sdf.org
Reply-To: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Subject: playing audio in firefox doesn't work after kernel update
X-Send-Pr-Version: www-1.0

>Number:         54177
>Category:       kern
>Synopsis:       playing audio in firefox doesn't work after kernel update
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    isaki
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 08 16:00:00 +0000 2019
>Closed-Date:    Fri May 24 13:11:34 +0000 2019
>Last-Modified:  Sat May 25 13:50:01 +0000 2019
>Originator:     coypu
>Release:        NetBSD 8.99.39
>Organization:
>Environment:
NetBSD plu 8.99.39 NetBSD 8.99.39 (GENERIC) #3: Wed May  8 18:34:58 IDT 2019  fly@plu:/home/fly/obj3/sys/arch/amd64/compile/GENERIC amd64

>Description:
audio in cmus/mpv: works good
audio in firefox: broken. sometimes it will play a few seconds fine though.
either playing a local file or youtube.

using:
[     1.051947] hdaudio0 at pci0 dev 31 function 3: HD Audio Controller
[     1.051947] hdaudio0: interrupting at msi4 vec 0
[     1.051947] hdafg0 at hdaudio0: vendor 10ec product 0298
[     1.051947] hdafg0: DAC00 2ch: Speaker [Built-In]
[     1.051947] hdafg0: DAC01 2ch: HP Out [Jack]
[     1.051947] hdafg0: ADC02 2ch: Mic In [Built-In]
[     1.051947] hdafg0: 2ch/2ch 44100Hz 48000Hz PCM16 PCM20 PCM24
[     1.051947] audio0 at hdafg0: full duplex, playback, capture, mmap, independent
[     1.051947] audio0: slinear_le:16 2ch 48000Hz, blk 40ms for playback
[     1.051947] audio0: slinear_le:16 2ch 48000Hz, blk 40ms for recording
[     1.051947] spkr0 at audio0: PC Speaker (synthesized)
[     1.051947] wsbell at spkr0 not configured
[     1.051947] hdafg1 at hdaudio0: vendor 8086 product 2809
[     1.051947] hdafg1: DP00 8ch: Digital Out [Jack]
[     1.051947] hdafg1: 8ch/0ch 48000Hz PCM16*

>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Wed, 8 May 2019 16:10:40 +0000

 Ths is playing audio with OSS. it's a local patch in pkgsrc/www/firefox/patches/

From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@netbsd.org, coypu@sdf.org
Cc: kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel update
Date: Thu, 09 May 2019 01:20:54 +0900

 Hello,

 Have you experienced it prior to 8.99.39?
 What firefox (or pkgsrc) version do you use?
 What base release do you use?  In other words,
 8.x userland + 8.99.39 kernel or 8.99.39 userland + 8.99.39 kernel.

 Thanks,
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Wed, 8 May 2019 16:38:03 +0000

 firefox 66.0.3
 NetBSD 8.99.38 userland, just before the branch merge. from May 7.
 NetBSD 8.99.39 kernel, after the branch merge.

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Wed, 8 May 2019 17:51:16 +0000

 correction: if playing audio+video in mpv, the video is too slow.

 also, if I 'audiocfg list' I get errors.
 [   611.689506] audio_track_setinfo_check failed: slinear_le 16bit 14ch 44100Hz

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Wed, 8 May 2019 20:11:48 +0200

 Same here, latest kernel, userland from 8.99.37 (build on April 23).
 Playing audio via sun audio and mpg123 seems to work fine, while firefox
 and oss stutter badly.

 The old userland audiocfg seems to work:

 0: [*] audio0 @ hdafg1: vendor 10ec product 0670, 12 playback channels

 but kernel traces:

 [ 519.3205380] audio_track_setinfo_check failed: slinear_le 16bit 14ch 44100Hz
 [ 521.1216467] audio_track_setinfo_check failed: slinear_le 16bit 14ch 44100Hz

 Martin

From: Ryo ONODERA <ryo@tetera.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel update
Date: Fri, 10 May 2019 21:05:29 +0900

 Hi,

 On freshly build NetBSD/amd64 8.99.39 (kernel+userland),
 freshly installed www/firefox-66.0.5 (not committed yet)
 works fine for me.
 My www/firefox uses PulseAudio to play audio.
 Of course PulseAudio uses OSS.

 Tetsuya Isaki <isaki@pastel-flower.jp> writes:

 > The following reply was made to PR kern/54177; it has been noted by GNATS.
 >
 > From: Tetsuya Isaki <isaki@pastel-flower.jp>
 > To: gnats-bugs@netbsd.org, coypu@sdf.org
 > Cc: kern-bug-people@netbsd.org,
 > 	gnats-admin@netbsd.org,
 > 	netbsd-bugs@netbsd.org
 > Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel update
 > Date: Thu, 09 May 2019 01:20:54 +0900
 >
 >  Hello,
 >  
 >  Have you experienced it prior to 8.99.39?
 >  What firefox (or pkgsrc) version do you use?
 >  What base release do you use?  In other words,
 >  8.x userland + 8.99.39 kernel or 8.99.39 userland + 8.99.39 kernel.
 >  
 >  Thanks,
 >  ---
 >  Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>
 >  

 -- 
 Ryo ONODERA // ryo@tetera.org
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Sat, 11 May 2019 21:25:04 -0500 (CDT)

 I'm having similar trouble with Youtube videos played with firefox.

 The first second or so of a video plays and then everything starts
 chopping and stuttering.  The video doesn't really continue, seeming
 to wait for the audio to get its act together.

 I'm using firefox52 built with:

   PKG_DEFAULT_OPTIONS+=oss -pulseaudio -alsa

 My system:

 amd64 8.99.39 with:

 hdaudio0 at pci0 dev 27 function 0: HD Audio Controller
 hdaudio0: interrupting at msi0 vec 0
 hdafg0 at hdaudio0: vendor 10ec product 0888
 hdafg0: DAC00 2ch: Speaker [Jack]
 hdafg0: DAC01 2ch: HP Out [Jack]
 hdafg0: DIG02 2ch: SPDIF Out [Built-In]
 hdafg0: ADC03 2ch: Line In [Jack], Mic In [Jack]
 hdafg0: ADC04 2ch: Mic In [Jack]
 hdafg0: 2ch/2ch 44100Hz 48000Hz 96000Hz 192000Hz PCM16 PCM20 PCM24 AC3
 audio0 at hdafg0: full duplex, playback, capture, mmap, independent
 audio0: slinear_le:16 2ch 48000Hz, blk 40ms for playback
 audio0: slinear_le:16 2ch 48000Hz, blk 40ms for recording


 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
	 update
Date: Tue, 14 May 2019 01:52:11 +0900

 Isaki-san is currently AFK, but I have some discussion with
 Y.Sugahara-san (a co-author of isaki-audio2 branch).

 I'd like to summarize what's going on current audio2 kernel
 and pkgsrc firefox.

 - the problem is not on individual hardware driver, but
   possible inconsistency between MI audio and ossaudio compat layer

 - the firefox upstream droped official OSS support long ago

 - pkgsrc has own patch file, patch-media_libcubeb_src_cubeb__oss.c:
    http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/www/firefox/patches/patch-media_libcubeb_src_cubeb__oss.c
    http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/pkgsrc/www/firefox/patches/patch-media_libcubeb_src_cubeb__oss.c?rev=1.12&content-type=text/plain

 - the oss support patch seems derived from FreeBSD ports:
  https://github.com/freebsd/freebsd-ports/blob/cd8036681e83301a86135acd26900d1eaf495d29/www/firefox/files/patch-bug1021761
   but they has also removed their local patches as "No upstream maintainer":
  https://github.com/freebsd/freebsd-ports/commit/098a888c8d8ec393674d12df7494fb81efbe12d8#diff-ee613bc8b4f46e2a591162768020ab92

 - firefox's cubeb_oss.c calls the following OSS ioctl's:
   SNDCTL_DSP_SETFRAGMENT
   SNDCTL_DSP_CHANNELS
   SNDCTL_DSP_SPEED
   SNDCTL_DSP_GETODELAY
   SNDCTL_DSP_CURRENT_OPTR
   SNDCTL_DSP_GETOPTR
   and probably something wrong in GETODELAY and/or GETOPTR

 - MI audio layer has proper infomation for GETODELAY,
   but there is no public API to pass it to oss compat layer,
   and SNDCTL_DSP_GETOPT seems to return some bogus value

 - Sugahara-san says cubeb_oss.c seems to have some buggy code
   (cubeb function that calls setfragment() assumes latency in millisecond
    but gecko seems to assume a number of frames?)

   -> there is a possibility that cubeb_oss.c is implemented for
      oss layer with some bugs (or weird compatibility) and
      it stops working after isaki-audio2 cleanup


 I'm afraid we need to prepare some bug-compatibility code for oss
 for unofficial firefox patch..

 ---
 Izumi Tsutsui

From: Jason Thorpe <thorpej@me.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 coypu@sdf.org
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Mon, 13 May 2019 09:57:38 -0700

 > On May 13, 2019, at 9:55 AM, Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> wrote:
 > 
 > - the firefox upstream droped official OSS support long ago

 What audio interface does Firefox prefer?

 -- thorpej

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Mon, 13 May 2019 18:59:35 +0200

 On Mon, May 13, 2019 at 04:55:01PM +0000, Izumi Tsutsui wrote:
 >    -> there is a possibility that cubeb_oss.c is implemented for
 >       oss layer with some bugs (or weird compatibility) and
 >       it stops working after isaki-audio2 cleanup
 >  
 >  
 >  I'm afraid we need to prepare some bug-compatibility code for oss
 >  for unofficial firefox patch..

 I would not worry too much about binary compaibility for a single app that
 everyone *really* needs to update every other month or so.

 If the problem is well understood, the bugs in cubeb_oss.c are fixed and
 new binaries work fine with the new audio code, all should be fine.

 Martin

From: Martin Husemann <martin@duskware.de>
To: Jason Thorpe <thorpej@me.com>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, coypu@sdf.org
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Mon, 13 May 2019 19:00:30 +0200

 On Mon, May 13, 2019 at 09:57:38AM -0700, Jason Thorpe wrote:
 > What audio interface does Firefox prefer?

 It depends on the OS and they do not do a proper NetBSD release themselves,
 so I would argue it is our call.

 Martin

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: martin@duskware.de
Cc: thorpej@me.com, gnats-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernelupdate
Date: Tue, 14 May 2019 02:48:34 +0900

 > > What audio interface does Firefox prefer?
 > 
 > It depends on the OS and they do not do a proper NetBSD release themselves,
 > so I would argue it is our call.

 For me both pulseaudio and alsa options worked.

 Possible problems are:

 (1) pulseaudio
  - pulseaudio defaults are not NetBSD friendly
   - mmap issue (patched in pkgsrc)
    http://mail-index.netbsd.org/pkgsrc-changes/2015/12/25/msg133989.html
   - too much RAM via shm_open(3) due to our shm_open implementation
     (uses tmpfs for shm_open(9) but pulseaudio requires 32MB for each app)
    -> it would be better to disable shm (i.e. set "enable-shm = no"
       in ~/.config/pulse/daemon.conf or /usr/pkg/etc/pulse/daemon.conf)
       but it is not default
   - annoying warning message on every startup of pulseaudio daemon
 >>   W: [(null)] caps.c: Normally all extra capabilities would be dropped now,
 >>   but that's impossible beause PulseAudio was built without capabirities
 >>    support.
     due to lack of "capabilities" support
     https://linuxjm.osdn.jp/html/LDP_man-pages/man7/capabilities.7.html
   - pkgsrc pulseaudio requires spidermonkey17, but it's extremely huge
   - Linux binaries that use pulseaudio (adobe-flash-player, for example)
     do not work on NetBSD/amd64 (PR/50603)
   - pulseaudio requires dbus daemon running (via /etc/rc.d)

 (2) alsa
  - alsa would be better even for NetBSD because users can choose
    oss or pulseaudio in ~/.asoundrc or /etc/asound.conf
  - possible problem is lack of documentation?
   http://mail-index.netbsd.org/netbsd-users/2009/02/11/msg003038.html
   http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/audio/alsa-plugins-pulse/MESSAGE?rev=1.1&content-type=text/x-cvsweb-markup
  - it also requires alsa-plugins-oss or alsa-plugins-pulse packages
    but not explicitly mentioned?

 Probably I have to prepare an English version of this blog page..
  https://ch.nicovideo.jp/tsutsui/blomaga/ar1166538

 ---
 Izumi Tsutsui

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after
 kernelupdate
Date: Mon, 13 May 2019 18:43:18 +0000

 It's not just firefox that is broken. mpv drops frames. this breaks
 audio-video synchronization.

 I don't consider pulseaudio an acceptable option.

Responsible-Changed-From-To: kern-bug-people->isaki
Responsible-Changed-By: isaki@NetBSD.org
Responsible-Changed-When: Mon, 20 May 2019 07:23:05 +0000
Responsible-Changed-Why:
Mine.


From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: coypu@sdf.org, gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernelupdate
Date: Mon, 20 May 2019 16:20:22 +0900

 At Mon, 13 May 2019 18:45:01 +0000 (UTC),
 coypu@sdf.org wrote:
 >  It's not just firefox that is broken. mpv drops frames. this breaks
 >  audio-video synchronization.
 >  
 >  I don't consider pulseaudio an acceptable option.

 Please send another new PR about mpv.
 We aren't sure yet whether these are the same problem or not.

 Thanks,
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: gnats-bugs@netbsd.org, coypu@sdf.org, martin@duskware.de
Cc: kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel update
Date: Tue, 21 May 2019 21:39:26 +0900

 At Wed,  8 May 2019 18:15:01 +0000 (UTC),
 Martin Husemann wrote:
 >  The old userland audiocfg seems to work:
 >  
 >  0: [*] audio0 @ hdafg1: vendor 10ec product 0670, 12 playback channels
 >  
 >  but kernel traces:
 >  
 >  [ 519.3205380] audio_track_setinfo_check failed: slinear_le 16bit 14ch 44100Hz
 >  [ 521.1216467] audio_track_setinfo_check failed: slinear_le 16bit 14ch 44100Hz

 This message will be shown if you use old audiocfg.
 But it was verbose.  Previous audio driver returned EINVAL silently
 if the same thing happened.  I should follow it.


 Here is details.
 In the past, there was no way that userland apps know the number of
 channels of hardware driver.  Then audiocfg attempted to set
 channels 2, 4, 6,..., 16.  This method used to work at that point.

 In netbsd-8, this operation was changed to software channel and the
 kernel limited it to 12 in 2017 (See also PR/52435).  Therefore
 audiocfg on netbsd-8 always shows 12 channels regardless of hardware.
 # And trying to set 14 channels fails.

 In audio2, I introduced AUDIO_QUERYFORMAT ioctl for this purpose
 and new audiocfg(1) uses it to know hardware information.  Then such
 problems are gone.

 Thanks,
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

From: "Tetsuya Isaki" <isaki@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54177 CVS commit: src/sys/dev/audio
Date: Tue, 21 May 2019 12:52:57 +0000

 Module Name:	src
 Committed By:	isaki
 Date:		Tue May 21 12:52:57 UTC 2019

 Modified Files:
 	src/sys/dev/audio: audio.c

 Log Message:
 Adjust debug message.  Inspired from PR kern/54177.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/sys/dev/audio/audio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Tetsuya Isaki" <isaki@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54177 CVS commit: src/sys/dev/audio
Date: Thu, 23 May 2019 12:20:27 +0000

 Module Name:	src
 Committed By:	isaki
 Date:		Thu May 23 12:20:27 UTC 2019

 Modified Files:
 	src/sys/dev/audio: audio.c audiodef.h

 Log Message:
 Remove unnecessary file lock.
 It has been introduced to prevent multiple syscalls entering
 simultaneously.  But it's completely unnecessary.
 It fixes firefox problem in PR kern/54177.


 To generate a diff of this commit:
 cvs rdiff -u -r1.8 -r1.9 src/sys/dev/audio/audio.c
 cvs rdiff -u -r1.2 -r1.3 src/sys/dev/audio/audiodef.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Thu, 23 May 2019 23:50:19 +0000

 Thanks that makes firefox work (without changes)
 mpv drops frames still, I can make a separate bug for this.

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: PR/54177 CVS commit: src/sys/dev/audio
Date: Fri, 24 May 2019 06:30:36 +0000

 I don't have a way to reproduce it reliably, but I had audio stop
 playing in firefox completely.
 killing it and starting firefox again worked.

From: Tetsuya Isaki <isaki@pastel-flower.jp>
To: coypu@sdf.org
Cc: gnats-bugs@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: PR/54177 CVS commit: src/sys/dev/audio
Date: Fri, 24 May 2019 22:02:32 +0900

 At Fri, 24 May 2019 06:35:01 +0000 (UTC),
 coypu@sdf.org wrote:
 >  I don't have a way to reproduce it reliably, but I had audio stop
 >  playing in firefox completely.
 >  killing it and starting firefox again worked.

 Hmm.. Please send a new PR if you find details.
 Anyway I close this PR.
 ---
 Tetsuya Isaki <isaki@pastel-flower.jp / isaki@NetBSD.org>

State-Changed-From-To: open->closed
State-Changed-By: isaki@NetBSD.org
State-Changed-When: Fri, 24 May 2019 13:11:34 +0000
State-Changed-Why:
The firefox problem initially reported is now fixed.


From: Leonardo Taccari <leot@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel update
Date: Sat, 25 May 2019 15:24:36 +0200

 Hello coypu,

 coypu@sdf.org writes:
 >
 >  Thanks that makes firefox work (without changes)
 >  mpv drops frames still, I can make a separate bug for this.
 >  

 JFTR, for mpv problem I have filled PR kern/54230.


 Thanks!

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/54177: playing audio in firefox doesn't work after kernel
 update
Date: Sat, 25 May 2019 13:48:04 +0000

 I think nia fixed this.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.