Skip to content

Audio can not be decoded since 1.36.1 #78333

@Malacath-92

Description

@Malacath-92

Short: The function AudioContext.decodeAudioData() fails in 1.36.1 but not in 1.35.1, given the same data.

  • VSCode Version: 1.36.1-user and 1.37.0-insider
  • OS Version: Windows 10

Steps to Reproduce:

  1. Create extension with the following source:
import * as vscode from 'vscode';

let webviewPanel = vscode.window.createWebviewPanel(
    'extension_name',
    'Webview Name',
    vscode.ViewColumn.Two,
    {
        enableScripts: true
    }
);

export function activate(extensionContext: vscode.ExtensionContext) {
    let resourcePath = "vscode-resource:/path_to_some.mp3";

    webviewPanel.webview.html = `
<script type="text/javascript">
    const AudioContext = window.AudioContext || window.webkitAudioContext;
    const audioContext = new AudioContext();
    audioContext.resume();

    fetch('${resourcePath}')
        .then(response => {
            return response.arrayBuffer();
        })
        .then(buffer => {
            audioContext.decodeAudioData(buffer)
                .then(audioBuffer => {
                    let audio = audioContext.createBufferSource();
                    audio.buffer = audioBuffer;
                    audio.loop = true;

                    let analyser = audioContext.createAnalyser();
                    analyser.fftSize = 512;

                    audio.connect(analyser);
                    analyser.connect(audioContext.destination);
                    audio.start();
                })
                .catch(e => {
                    console.error("Error: " + e.message);
                });
        }).
        catch(e => {
            console.error("Error: " + e.message);
        });

    render();

    function render() {
        requestAnimationFrame(render);
    }
</script>
    `;
}
export function deactivate() {
    webviewPanel.dispose();
}
  1. When the extension is activated, a webview panel will load, which will report VM98:25 Error: Unable to decode audio data in the Webview Developer Tools. Also the following warning is reported: VM98:3 The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
  2. No audio plays.
  3. Compare with behavior of same extension in 1.35.1, where no warning or error is reported and audio plays.

Metadata

Metadata

Labels

upstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions