Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

When loading KMZs, I get an error when trying to access a ThirdParty/Workers/inflate.js

410 views
Skip to first unread message

and...@propelleraero.com.au

unread,
Jan 10, 2018, 1:16:35 AM1/10/18
to cesium-dev
I'm hosting my code in one place and accessing it from a different origin.

I get the following error when loading a KMZ.

"Uncaught DOMException: Failed to construct 'Worker': Script at 'https://YYYYY.com/ThirdParty/Workers/inflate.js' cannot be accessed from origin 'https://ZZZZZZ.com'."


This is because ThirdParty/zip.js tries to build a worker blindly using the domain that the code is sitting on. The worker code does exist at the target url, but the browser won't allow access to it.

```zip.js
if (obj.zip.useWebWorkers) {
worker = new Worker(obj.zip.workerScriptsPath + INFLATE_JS);
launchWorkerProcess(worker, reader, writer, offset, size, oninflateappend, onprogress, oninflateend, onreaderror, onwriteerror);
} else
launchProcess(new obj.zip.Inflater(), reader, writer, offset, size, oninflateappend, onprogress, oninflateend, onreaderror, onwriteerror);
return worker;
```

It looks like you should be able to set the `useWebWorkers` value on the zip instance, but there's no way to specify that from KmlDataSource.

Is there any way to get around creating these workers from a different domain? I know the other workers in cesium use the TaskProcessor factory to sidestep cors issues.

Can I somehow do this with the zip dependency?

I think this is the same issue referenced here https://cesiumjs.org/forum/#!topic/cesium-dev/mYpD1-fyjFs/discussion


Cesium Version 1.41.0
Chrome Version 63.0.3239.132

Gabby Getz

unread,
Jan 11, 2018, 5:18:57 PM1/11/18
to cesium-dev
Hi Andrew,

zip.js is third party code we include in the Cesium library. The fix here may just be to modify that third party code in order to build the web worker url consistently with the rest of the Cesium library. However, it is just building a url relative to the cesium base location and loading that script.

If you could provide a code snippet with your use case, that would help track down what exactly we can do to work around this issue.

Thanks!
Gabby

Andrew McDowell

unread,
Jan 11, 2018, 5:24:35 PM1/11/18
to cesiu...@googlegroups.com

Hi Gabby,
I came to this conclusion of modifying zip.js too after looking back through the commits and seeing that it's already been modified to import buildModuleUrl to add the correct workerScriptsPath.
I've taken inspiration from the TaskProcessors's getWorkerUrl for this.
I have prepared a small PR and will likely submit it today following the guidelines laid out in GitHub.
Thanks for your help,
Andew


--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/dq2l5L69L0U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Andrew McDowell

logo.png

Visualiser Team - Frontend Wizard | +61 481516548 | and...@propelleraero.com

propelleraero.com | we’re hiring! | latest news

twitter.png  linkedin.png  facebook.png

Gabby Getz

unread,
Jan 12, 2018, 10:42:24 AM1/12/18
to cesium-dev
Thanks, Andrew! I see your PR on github and we should get it reviewed shortly! Thanks for the contribution!
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages