加载模块时 AudioWorklet DOMException 错误 [英] AudioWorklet DOMException error when loading modules

查看:28
本文介绍了加载模块时 AudioWorklet DOMException 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 WebAudio 应用程序,它需要 AudioWorklets 并且需要来自许多不同脚本的函数以在 process() 函数中使用.因此,我尝试使用 import 命令在 processor 脚本 (frictionProcessor.js) 中加载所述脚本,如下所示:

I'm working on a WebAudio application that requires AudioWorklets and needs functions from many different scripts to be used in the process() function. Therefore, I'm trying to load said scripts in the processor script (frictionProcessor.js) with the import command as shown:

import {MAX_ERROR, MAX_ITERATIONS} from "./utilities.js";  
class FrictionProcessor extends AudioWorkletProcessor {...}
registerProcessor('frictionProcessor', FrictionProcessor);

其中 utilities.js 是:

//Constants
const MAX_ERROR = 0.001;
const MAX_ITERATIONS = 50;
const MAX_POS = 10000.0;
const LCG_MULT = 1664525;
const LCG_ADD = 1013904223;

这给出了错误:未捕获(承诺)DOMException:用户中止请求.
当注释带有 import 的行时,此错误消失,但我需要加载很多模块(不仅是此处显示的模块),因此不使用它不是一种解决方法.

This gives the error: Uncaught (in promise) DOMException: The user aborted a request.
This error disappears when the line with the import is commented, but I need to load a lot of modules (not only the one shown here), so just not using it is not a workaround.

我发现的最接近的问题是:AudioWorklet 错误:DOMException: 用户中止了一个请求.然而,这并没有多大帮助,因为我不确定如何使用 application/javascript 为工作集处理器提供服务,因为它是用 addModule 函数加载的.

The closest question I've found is: AudioWorklet error: DOMException: The user aborted a request . However, this was not of much help, because I am not sure of how to serve the worklet-processor with application/javascript since it is loaded with the addModule function.

另一方面,我尝试了 https://developers.google.com/web/updates/2018/06/audio-worklet-design-pattern ,它们工作正常.

On the other hand, I've tried the design-pattern example codes from https://developers.google.com/web/updates/2018/06/audio-worklet-design-pattern , and they work fine.

我使用 Chrome 69 和 Web Server for Chrome 作为本地主机.

I'm using Chrome 69 and Web Server for Chrome as the local host.

有谁知道为什么会发生这种情况,或者如何避免这种情况?该错误是反复出现的,并且不完全是不言自明的.

Does anybody know why this is happening, or how to avoid it? The error is recurrent and not quite self-explanatory.

谢谢

推荐答案

也许你的 utilities.js 应该是:

const MAX_ERROR = 0.001;
const MAX_ITERATIONS = 50;
const MAX_POS = 10000.0;
const LCG_MULT = 1664525;
const LCG_ADD = 1013904223;

export {
  MAX_ERROR,
  MAX_ITERATIONS,
  MAX_POS,
  LCG_MULT,
  LCG_ADD,
};

此外,任何评估/解析错误都将导致 DOMException.我同意这可以改进.我为它提交了一个错误.

Also any evaluation/parse error will result in a DOMException. I agree that this this could be improved. I filed a bug for it.

这篇关于加载模块时 AudioWorklet DOMException 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆