New issue
Advanced search Search tips

Issue 807160 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

[audioworklet] Can't load "data:" urls with mimetype application/javascript

Reported by shakt...@gmail.com, Jan 30 2018

Issue description

Chrome Version       : 64.0.3282.119 (Official Build) (64-bit)

What steps will reproduce the problem?
(1) Enable AudioWorklets in Chrome (https://developers.google.com/web/updates/2017/12/audio-worklet#experimental)

(2) Load the attached file, audioworklet_test_application_javascript.html

(3) Listen for noise, check the console.

What is the expected result?
It should generate noise through the speakers.

What happens instead?
It generates an alert in the console:
"Uncaught (in promise) DOMException: the user aborted a request."
Tested on Mac Chrome and Linux Chrome.

Please provide any additional information below. Attach a screenshot if
possible.
The same test works if you change the MIME Type of the data URL from application/javascript to text/javascript. Both MIME Types work with "blob:" urls generated from URL.createObjectURL.
 
audioworklet_test_application_javascript.html
648 bytes View Download
Cc: nhiroki@chromium.org
Components: Blink>Workers
Status: Available (was: Unconfirmed)
nhiroki@

I believe loading script is done by the module loader. Perhaps we have a bug in handling different MIME types? I had a similar report from WebAudio slack channel before, but we solved the issue by using "text/javascript" as well.
Labels: Needs-Triage-M64
Cc: kouhei@chromium.org
+kouhei@: Does the module loader support "data:" urls with "application/javascript"? I'd like to identify if this is an issue in the worklet side or the module loader side before spending time on debugging.

Comment 4 by kouhei@chromium.org, Jan 31 2018

Cc: hirosh...@chromium.org
Components: Blink>HTML>Script
Owner: hirosh...@chromium.org
hiroshige: Would you triage this? Sorry I'm too busy today
Module loader's MIME check refers
https://codesearch.chromium.org/chromium/src/third_party/WebKit/common/mime_util/mime_util.cc?gsn=IsSupportedJavaScriptMIMEType&l=42
and "application/javascript" is listed there as well as "text/javascript".
So I expect the MIME type check passes in module script side.

Comment 6 by kouhei@chromium.org, Jan 31 2018

Owner: nhiroki@chromium.org
passing the ball back to nhiroki
Thank you for the quick reply! :)
Components: -Blink>HTML>Script -Blink>WebAudio -Blink>Workers Blink>Loader
Owner: ----
It seems whitespaces in data URL response are stripped if the MIME type is application/javascript.

fetch('data:application/javascript,foo bar').then(r => r.text()).then(r => console.log(r));
=> foobar

fetch('data:text/javascript,foo bar').then(r => r.text()).then(r => console.log(r));
=> foo bar

So not related to modules or worklets.
The same result on Firefox > fetches in Comment #8.

Due to the whitespace stripping, a parse error occurs and thus the worklet fails.

According to:
https://tools.ietf.org/html/rfc2397
https://en.wikipedia.org/wiki/Data_URI_scheme
https://codesearch.chromium.org/chromium/src/net/base/data_url.cc?type=cs&l=93

Whitespaces in data URL are not allowed and should be escaped instead, and Chromium seems to intentionally strip them (except for text/ and xml types).

Sign in to add a comment