Search code examples
web-workercesiumjs

Cesium TaskProcessor vs Web Worker


I need to process a large amount of data. I was wondering if there are any reasons to use Cesium's TaskProcessor rather than a typical Web Worker?


Solution

  • Cesium's TaskProcessor wraps the existing Web Worker system to return a Promise. Cesium uses an internal copy of the when.js library to manage asynchronous activities with promises. Cesium also takes some extra steps to determine if TypedArrays transfer correctly from web workers, as some browsers have issues there. TypedArrays are needed for transferring data to WebGL, such as vertex data, and Cesium uses TaskProcessors to prepare some of this data outside of the main UI thread.