AudioWorklet DOMException error when loading modules

笑着哭i 提交于 2019-12-12 20:22:23

问题


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);

where utilities.js is:

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

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.

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.

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.

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.

Thank you


回答1:


Perhaps your utilities.js should be:

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,
};

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



来源:https://stackoverflow.com/questions/52636370/audioworklet-domexception-error-when-loading-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!