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(
               new Blob(
                  ["requestAnimationFrame(() => this.postMessage('requestAnimationFrame in web-worker process'))"]
                  , { type: "text/javascript" })));

worker.addEventListener("message", e =>

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?

>Solution :

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.

Leave a Reply