Home > Software design >  requestAnimationFrame is not defined in web-worker in Firefox?
requestAnimationFrame is not defined in web-worker in Firefox?

Time:06-11

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?

CodePudding user response:

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.

  • Related