简体   繁体   中英

requestAnimationFrame is not defined in web-worker in Firefox?

I can't find any information why Firefox v91.10.0esr on Windows 10 complains that requestAnimationFrame is not defined:

 const worker = new Worker( URL.createObjectURL( new Blob( ["requestAnimationFrame(() => this.postMessage('requestAnimationFrame in web-worker process'))"], { type: "text/javascript" }))); worker.addEventListener("message", e => { console.log(e.data); }); requestAnimationFrame(() => console.log("requestAnimationFrame in main process"));

19:09:53.100 ReferenceError: requestAnimationFrame is not defined 569ddce0-b6c3-47c9-88b4-89d59445b335:1:1
    <anonymous> blob:null/569ddce0-b6c3-47c9-88b4-89d59445b335:1

It works fine on Android Firefox and other browsers (Edge, Chrome).

Any ideas?

Firefox added support for requestAnimationFrame and cancelAnimationFrame in workers with v97 as you can see on this issue . Comment 17 and 18 just confirm it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM