Bug 229325

Summary: Decoding webm file with more than 2 channels will fail
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: Web AudioAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: NEW ---    
Severity: Normal CC: cdumez, eric.carlson, ews-watchlist, glenn, hartman.wiki, jer.noble, padenot, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 227111    
Attachments:
Description Flags
Patch none

Description Jean-Yves Avenard [:jya] 2021-08-20 00:58:21 PDT
Decoding of webm with more than 2 channels will fail with a decoding error.

STR:
1- Open https://jyavenard.github.io/htmltests/tests/webaudio/decodeAudioData.html
2- Select opus-mapping2.webm in the drop down list
3- press play

Result: will show a decoding error as context.decodeAudioData return an error
Comment 1 Radar WebKit Bug Importer 2021-08-20 00:58:49 PDT
<rdar://problem/82160691>
Comment 2 Jean-Yves Avenard [:jya] 2021-09-07 19:19:20 PDT
Created attachment 437580 [details]
Patch
Comment 3 Eric Carlson 2021-09-08 09:42:28 PDT
Comment on attachment 437580 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437580&action=review

> Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:175
> +        setVorbisChannelMap(layout, cookie.channelCount);

Why do you set the *Vorbis* channel map with an Opus cookie? A comment would be helpful.
Comment 4 Jean-Yves Avenard [:jya] 2021-09-08 15:41:45 PDT
Comment on attachment 437580 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437580&action=review

> Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:176
> +        m_channelLayout = layout;

https://datatracker.ietf.org/doc/html/rfc7845#section-5.1.1.2

mapping family one uses the vorbis layout.
Comment 5 Eric Carlson 2021-09-09 08:32:00 PDT
Comment on attachment 437580 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=437580&action=review

>> Source/WebCore/platform/graphics/cocoa/WebMAudioUtilitiesCocoa.mm:176
>> +        m_channelLayout = layout;
> 
> https://datatracker.ietf.org/doc/html/rfc7845#section-5.1.1.2
> 
> mapping family one uses the vorbis layout.

Yes, my point is that someone unfamiliar with the RFC may be confused by code so a comment would be helpful.
Comment 6 Derk-Jan Hartman 2022-03-24 16:15:33 PDT
This problem still exists:
Example: https://upload.wikimedia.org/wikipedia/commons/d/d3/Elephants_Dream_%282006%29.120p.vp9.opus.multichannel.webm

No downsampling occurs and video playback fails. Because canPlayType passes, no fallback can occur to another source (like webm vp8, vorbis) either, creating a broken experience for the user.

This is unfortunate as multichannel is supported by the format and it means that for Wikimedia we will now have to downsample all our derivatives/transcodes to stereo, if we do not want such files to break on macOS. This denies users of Chrome and Firefox the benefit of proper multichannel sound.

Last tested on Safari 15.4 and STP 142, macOS 12.3 on a MacBook Pro from 2021.
Wikimedia ticket: https://phabricator.wikimedia.org/T304624
Comment 7 Jean-Yves Avenard [:jya] 2022-03-24 19:42:34 PDT
(In reply to Derk-Jan Hartman from comment #6)
> This problem still exists:
> Example:
> https://upload.wikimedia.org/wikipedia/commons/d/d3/
> Elephants_Dream_%282006%29.120p.vp9.opus.multichannel.webm
> 

It still exists because it hasn’t been fixed. 

The framework decoder unfortunately lacks the ability to decode more than 2 channels file
Comment 8 Alexey Proskuryakov 2023-11-25 13:53:33 PST
*** Bug 241220 has been marked as a duplicate of this bug. ***