Skip to content
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 call to ApproximateTerrainHeights.initialize from GroundPolylinePrimitive #6715

Closed
wants to merge 1 commit into from

Conversation

hpinkos
Copy link
Contributor

@hpinkos hpinkos commented Jun 21, 2018

Fixes #6711

@likangning93 can you review and merge?

@cesium-concierge
Copy link

Signed CLA is on file.

@hpinkos, thanks for the pull request! Maintainers, we have a signed CLA from @hpinkos, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@hpinkos
Copy link
Contributor Author

hpinkos commented Jun 21, 2018

No need to update CHANGES.md because this bug was never released

@@ -382,7 +382,7 @@ define([
return initPromise;
}

GroundPolylinePrimitive._initPromise = ApproximateTerrainHeights.initialize('../Assets/approximateTerrainHeights.json')
GroundPolylinePrimitive._initPromise = ApproximateTerrainHeights.initialize()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hpinkos this seems to cause the JSON load to fail for local hosted and unproxied (?) apps. I'm getting a runtime error for the deployed Sandcastle demos:
http://cesium-dev.s3-website-us-east-1.amazonaws.com/cesium/fix-approx-heights/Apps/Sandcastle/index.html?src=Polyline.html

Is there a good way to test this with a proxy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApproximateTerrainHeights.initialize needs to use buildModuleUrl like everything else, never load a Cesium required asset without it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, this is what GroundPrimitive does already so this should be the right thing to do. I don't know where that runtime error is coming from. I'll see if I can figure it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mramato ApproximateTerrainHeights.initialize does use buildModuleUrl

Copy link
Contributor Author

@hpinkos hpinkos Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I this is happening because ApproximateTerrainHeights is being used by GroundPolylinePrimitive in a webworker

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry about this >__<

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably no one has ever tried to use buildModuleUrl from a worker, which is pretty unusual. I suspect an easier path would be to load the terrain height data in the main thread and send the data across, rather than trying to re-load it independently in the worker.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively you could compute the full absolute url and send that across to the worker.

@likangning93
Copy link
Contributor

I suspect an easier path would be to load the terrain height data in the main thread and send the data across, rather than trying to re-load it independently in the worker.

@shunter this seems sensible, but before diving in, the terrain heights are a giant (~500 kb) JSON. Should we keep that around on the main thread as a string to avoid having to re-stringify? Or should we just let that happen and not worry about the additional cost on spinning up workers?

Alternatively I guess there's the rabbit hole of making the terrain heights JSON packable to a typed array... and accessing that typed array instead of traversing the JSON... but maybe that's out of scope for right now?

@likangning93
Copy link
Contributor

likangning93 commented Jun 21, 2018

I'm going to get started with just letting the stringification happen for now, since that seems simplest. compute is cheap (ish)

[EDIT] yeah, some simple console.time tests suggest stringify and parse are reasonably quick even on Chrome on a "low end" machine I have lying around (think Chromebook).

@shunter
Copy link
Contributor

shunter commented Jun 21, 2018

Well it looks like the entire JSON array is kept permanently in memory anyway as ApproximateTerrainHeights._terrainHeights so you could just send and restore that.

@likangning93
Copy link
Contributor

Cool, @shunter looks like this should work.

@bagnell #6615 added a bunch of async stuff to our workers so geometry could be created asynchronously on the worker itself. I'm going to go ahead and revert that, we can revisit it once geometry creation actually needs to be async like for querying a server for terrain heights or something.

@likangning93
Copy link
Contributor

Opened a new PR here: #6716

@hpinkos ok to close this?

@hpinkos
Copy link
Contributor Author

hpinkos commented Jun 21, 2018

Yep, thanks for taking this one over @likangning93!

@hpinkos hpinkos closed this Jun 21, 2018
@hpinkos hpinkos deleted the fix-approx-heights branch June 21, 2018 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants