简体   繁体   中英

Web Worker in Safari

I recently use web worker for a PWA and I call to Self.RequestAnimationFrame() in my worker. But problem is just in Safari browser it's fire Exception that RequestAnimationFrame() does not exist. The question is :

  • Am I calling it wrong ? or
  • Is there any other solution for this situation?

WorkerScope.requestAnimationFrame (note the lower-cased r ) has been added only very recently in the standards, and as of today, only Chrome based browsers do support it.
Note that it has been added so that we can use it with OffsreenCanvas, using this method outside of this use has very little sense since your Worker is otherwise disconnected from the monitor.

Given that you didn't tell why you need this method, it's quite hard to find the proper equivalent, but chances are that a simple setTimeout(fn, 16) would do, or if it's to respond to some animation that occurs in the main thread, then just respond to onmessage events.

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