New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: TaskProcessor
cross-origin worker loading
#11833
Fix: TaskProcessor
cross-origin worker loading
#11833
Conversation
Hi @harrythemorris, I don't see a CLA on file on file for you. We'll need this before we can review this PR. See Let us know once that's submitted. Thanks! |
Hi @ggetz sorry for the trouble! My employer PropellerAero have signed a corporation CLA - are there any steps that I need to take to verify that I am a member of the org? |
No worries @harrythemorris! I see PropellerAero, but I don't see your user ID or name listed under "Schedule A". Would you be able to have your admin or point of contact update the list? |
Heyo @ggetz! I'm the CTO of PropellerAero and we haven't contributed here in a little while as an org so that list is quite out of date. How would we go about updating it for Propeller Aero? The best contact on that list to confirm details would be @keattang if you could send email correspondence to him? |
@jaycosaur @keattang The simplest approach would be to re-submit the Corporate CLA with new usernames. |
Actually, a vouch from @keattang via a comment here would be enough. |
Hi @ggetz! I vouch for both @jaycosaur and @harrythemorris. If they can be allowed to vouch for other people that would be great too. Let me know if you'd like me fill out any forms or need any other details 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @harrythemorris!
I seem to be having trouble replicating the issue. Would you mind giving us a few more details about how the application is being bundled?
try { | ||
await taskProcessor.scheduleTask(); | ||
} catch { | ||
// We expect this to throw as we cannot setup a true cross-origin base in tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it possible to call dummy code instead such that this doesn't throw? For example, could the blob spy return a blobbed dummy script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the ability to skip running the task for testing purposes in 20d9671
Mocking out a dummy worker script with necessary message handlers so that it doesn't hang got a bit bulky and I think this results in a cleaner test, but happy to revisit if you'd prefer to avoid this approach
CHANGES.md
Outdated
@@ -8,6 +8,8 @@ | |||
|
|||
- Fixed a bug affecting voxel shader compilation in WebGL1 contexts. [#11798](https://github.com/CesiumGS/cesium/pull/11798) | |||
- Fixed a bug where legacy B3DM files that contained glTF 1.0 data that used a `CONSTANT` technique in the `KHR_material_common` extension and only defined ambient- or emissive textures (but no diffuse textures) showed up without any texture [#11825](https://github.com/CesiumGS/cesium/pull/11825) | |||
- Fixed a bug where `TaskProcessor` worker loading would check the worker module ID rather than the absolute URL when determining if it is cross-origin. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a link to this PR given there is no original issue.
Hi @ggetz I've put together a minimal repro here based on the cesium-webpack-example. Essentially:
This webpack setup emulates this, with the webpack dev server standing in for Origin A, serving the bundle and static assets, and the I've updated the PR description with a link to this, and have added screenshots of the errors that occur. Let me know if you have any more trouble reproducing, and I can try to get this setup somewhere publicly accessible. |
Thanks for the test repo @harrythemorris! I can reproduce the runtime error! When I use this branch in that example instead of main, the runtime rendering error goes away, but I'm still seeing CORS errors in the console for other assets. I understand this PR focuses on workers, but is this expected? |
Hi @ggetz Not expected! I am not seeing those errors here when running on my machine - all static assets are loading successfully (e.g. skybox, workers, widgets/). To test my branch, I used |
@harrythemorris I tried again, and I'm still seeing the CORS errors in Chrome. I'm not seeing them in Firefox though. In this branch, I ran
and in your provided sample repo I ran
Strictly speaking this doesn't need to hold up this PR, but I want to make sure we're addressing the core issue before merging. |
@ggetz thanks again for taking the time to try this out 🙏 I believe the issue stems from (I've also resolved the conflict and moved my CHANGES to next release) |
Hi @ggetz just wanted to bump this one - I believe the above concerns have been addressed, and I've resolved all conflicts ready to merge. |
Thanks for your patience @harrythemorris! I tweaked the unit test to remove the reliance on a |
Description
Fixes two issues that we have come across when upgrading to the latest version of Cesium with our unusual setup, where our application bundle and Cesium resources are loaded cross-origin.
createWorker
function uses the module ID rather than a full URI when considering whether to load the worker with a cross-origin shim. This results in e.g.SecurityError: Failed to construct 'Worker': Script at 'http://localhost:8080/cesiumStatic/Workers/createVerticesFromQuantizedTerrainMesh.js' cannot be accessed from origin 'http://localhost:3003'.
importScripts
method does not support ESM modules. It will fail at runtime with errorUncaught TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope': Module scripts don't support importScripts().
Issue number and link
Could not find any related issues.
Testing plan
A minimal reproduction is available here.
To reproduce issue:
importScripts
shim, which gives vague and unhelpful errors when loading ESM modules.The net result is Cesium unable to render the globe, erroring out before any display.
With the fixes, it should initialise as usual.
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my change