Skip to content

Commit 6792010

Browse files
committed
Playback of application/ogg blob media is broken
rdar://163119790 https://bugs.webkit.org/show_bug.cgi?id=301509 Reviewed by Jean-Yves Avenard. When loading through blob, WebCoreAVFResourceLoader is used. `application/ogg` mime type does not lead to a valid UTI and AV player is not able to recover itself. Mime Sniffer is used but it will still return `application/ogg`. We update MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL to use `audio/ogg` in case `application/ogg` is the preferred mime type. We only do this for blob URLs and should follow-up for all URLs. We skip the test on iOS due to the lack of ogg support there. Test: http/wpt/media/blob-and-ogg.html Canonical link: https://commits.webkit.org/304530@main
1 parent d5879b8 commit 6792010

File tree

6 files changed

+90
-0
lines changed

6 files changed

+90
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
PASS Playing audio/ogg with blobs should succeed
4+
PASS Playing application/ogg with blobs should succeed
5+
PASS Playing video/ogg with blobs should succeed
6+
PASS Playing bogus/ogg with blobs should succeed
7+
PASS Playing ogg without content type with blobs should succeed
8+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
</head>
8+
<body>
9+
<audio controls muted id=audio></audio>
10+
<script>
11+
async function validateAudioPlayback(url)
12+
{
13+
audio.src = url;
14+
return audio.play();
15+
}
16+
17+
async function doOggTest(test, contentType)
18+
{
19+
const audioConfig = {
20+
type: "file",
21+
audio: {
22+
contentType: 'audio/ogg; codecs="vorbis"',
23+
channels: '2'
24+
}
25+
};
26+
const result = await navigator.mediaCapabilities.decodingInfo(audioConfig);
27+
if (!result.supported)
28+
return;
29+
30+
const response = await fetch("resources/ogg-file.py?contentType=${contentType}");
31+
const blob = await response.blob();
32+
const blobUrl = URL.createObjectURL(blob);
33+
test.add_cleanup(() => URL.revokeObjectURL(blobUrl));
34+
35+
return validateAudioPlayback(blobUrl);
36+
}
37+
38+
promise_test(test => {
39+
return doOggTest(test, "audio/ogg");
40+
}, "Playing audio/ogg with blobs should succeed");
41+
42+
promise_test(test => {
43+
return doOggTest(test, "application/ogg");
44+
}, "Playing application/ogg with blobs should succeed");
45+
46+
promise_test(test => {
47+
return doOggTest(test, "video/ogg");
48+
}, "Playing video/ogg with blobs should succeed");
49+
50+
promise_test(test => {
51+
return doOggTest(test, "bogus/ogg");
52+
}, "Playing bogus/ogg with blobs should succeed");
53+
54+
promise_test(test => {
55+
return doOggTest(test, "resources/ogg-file.py");
56+
}, "Playing ogg without content type with blobs should succeed");
57+
</script>
58+
</body>
59+
</html>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os.path
2+
3+
from wptserve.utils import isomorphic_decode
4+
5+
def main(request, response):
6+
contentType = request.GET.first(b"contentType", b"")
7+
path = os.path.join(os.path.dirname(isomorphic_decode(__file__)), u"silence.ogg")
8+
body = open(path, "rb").read()
9+
10+
response.add_required_headers = False
11+
response.writer.write_status(200)
12+
response.writer.write_header(b"content-length", len(body))
13+
response.writer.write_header(b"content-type", path)
14+
response.writer.end_headers()
15+
16+
response.writer.write(body)
4.02 KB
Binary file not shown.

LayoutTests/platform/ios/TestExpectations

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ webaudio/codec-tests/vorbis [ Skip ]
298298
webaudio/decode-audio-data-webm-vorbis.html [ Failure ]
299299
media/track/audio-track-configuration-webm.html
300300

301+
# ogg not available in simulator
302+
http/wpt/media/blob-and-ogg.html [ Skip ]
303+
301304
# No wheel events on iOS
302305
fast/events/wheel [ Skip ]
303306
fast/scrolling/iframe-scrollable-after-back.html [ Skip ]

Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ static URL conformFragmentIdentifierForURL(const URL& url)
908908
auto type = player->contentMIMEType();
909909

910910
if (PAL::canLoad_AVFoundation_AVURLAssetOutOfBandMIMETypeKey() && !type.isEmpty() && !player->contentMIMETypeWasInferredFromExtension()) {
911+
// FIXME: Remove that check once AVFoundation allows it (rdar://163119790). This should also not be restricted to blobs.
912+
if (type == "application/ogg"_s && url.protocolIsBlob())
913+
type = "audio/ogg"_s;
914+
911915
auto codecs = player->contentTypeCodecs();
912916
if (!codecs.isEmpty()) {
913917
RetainPtr typeString = adoptNS([[NSString alloc] initWithFormat:@"%@; codecs=\"%@\"", type.createNSString().get(), codecs.createNSString().get()]);

0 commit comments

Comments
 (0)