Using web workers

I’ve started creating web workers using the API, and I just can’t get them to work.
Here’s my sample code:

var myAsyncProcess = new TaskProcessor('asyncProcess', Number.POSITIVE_INFINITY);

var promise = myAsyncProcess.scheduleTask([{
dataSource: dataSource

when(promise, function(result){

I have a file: asyncProcess.js in the workers directory which is also added in the build/combine process (I can see it in the build/CesiumUnminified/workers folder after the build, with all the added goodies the build/combine process adds to the file):

/global define/
], function(
createTaskProcessorWorker) {
“use strict”;

function asyncProcess(packedParameters, transferableObjects) {
    return 1;
return createTaskProcessorWorker(asyncProcess);


When debugging, I’ve seen the postMessage being called in the “scheduleTask” method, and it entered the asyncProcess.js file. It went over the “define” lines, but never got to the “debugger” lines (hence, probably never creating the processor worker…).

Any idea what might be the issue? Am I missing anything?


The dataSource object is probably not able to be cloned to send to the worker, so scheduleTask is likely rejecting the promise.

When working with promises, always add an otherwise at the end to detect rejected promises.

when(promise, function(result) {


}).otherwise(function(error) {



Changing the dataSource to a simple string (‘test’) was one of the first things I’ve tried. Still no good.

I’ve tried the otherwise statement and it never got there as well.

I’ve actually copied the file “combineGeometry.js” to make sure I got the same syntax, so all I changed was the file name and the method name. The rest I’ve left exactly the same. Still no good.

Other directions where it might fail?

For some reason it started working. It might have been something with chrome. The only difference was that I restarted the browser (was on for weeks now…).
Had no issue transferring the dataSource.

Thanks :slight_smile: