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

getTileDataAvailable() handling for terrain providers #2102

Merged
merged 16 commits into from
Sep 18, 2014
Merged

Conversation

chris-cooper
Copy link
Contributor

This is a tile loading optimisation for cameras that start near the globe based on advice from Kevin. It is currently only implemented for the Cesium terrain provider which knows in advance which tiles are present.

@chris-cooper
Copy link
Contributor Author

Profiling was done in the scenes under Specs/Profile. Profiling method was using Chrome developer tools 'Network' tab with 'Disable cache' enabled and 'stk-terrain' as a filter. Values are as per the summary line at the bottom of the network tab. Tests were repeated to take into account variations in network traffic etc. An interval is used in the profile scenes to set the camera otherwise it is automatically pushed above the low res terrain.

HalfDome.html

current master...

355/3746 requests | 2.0MB / 26.9MB transferred | 1.0min
335/3414 requests | 2.0MB / 25.9MB transferred | 53.96s
331/2952 requests | 2.0MB / 23.4MB transferred | 45.70s

tile-loading branch...

339/2912 requests | 2.0MB / 23.2MB transferred | 41.98s
335/2972 requests | 1.9MB / 23.7MB transferred | 43.74s
312/2909 requests | 1.9MB / 24.0MB transferred | 42.09s

SanFrancisco.html

current master...

294/2772 requests | 719KB / 17.2MB transferred | 43.69s
313/3635 requests | 731KB / 20.2MB transferred | 56.04s
300/3030 requests | 723KB / 17.6MB transferred | 44.71s
322/2800 requests | 740KB / 17.2MB transferred | 47.87s

tile-loading branch...

327/2669 requests | 748KB / 16.6MB transferred | 40.06s
315/2078 requests | 741KB / 14.1MB transferred | 31.18s
299/2018 requests | 723KB / 13.9MB transferred | 31.49s
319/2637 requests | 743KB / 16.4MB transferred | 37.10s

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 2, 2014

CC #526

* @param {Number} level The level of the tile for which to request geometry.
* @returns {Number} Undefined if not supported by the terrain provider, otherwise true or false.
*/
TerrainProvider.prototype.getTileDataAvailable = DeveloperError.throwInstantiationError;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change for folks who implemented TerrainProvider, right?

We should provide a default implementation to not break them and perhaps warn if we want to eventually require this. See the Deprecation Guide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see isDataAvailable below in GlobeSurfaceTile.js. Is that the right place? I would expect to treat this as an abstract base class instead so all users do not need to check for the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently there are no "base classes" or inheritance in Cesium. TerrainProvider only exists as documentation of an implicit interface, so there are no breaking changes here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. This is still a little sketchy. It's as if we want to document this function as optional so users know they need to check to see if the function exists or we need to start using inheritance of whatever form to avoid this.

Copy link
Member

Choose a reason for hiding this comment

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

It's as if we want to document this function as optional so users know they need to check to see if the function exists or we need to start using inheritance of whatever form to avoid this.

I believe inheritance would have a performance cost we'd rather not pay. I agree it should be documented as optional, though.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 2, 2014

Can you add tests and update CHANGES.md? Add a new 1.02 section; I don't think this will make 1.01 today.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 2, 2014

Thanks for this @chris-cooper. There is still a lot more we can do (dare, we not require loading parents before children?!?!?), but this is improvement is very welcomed.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 2, 2014

@kring do you want to have a look and merge when ready?

CC @abwood

@chris-cooper
Copy link
Contributor Author

OK thanks @pjcozzi. I've added some specs and moved one of the profiling tests to sandcastle and deleted the other since the timings weren't hugely different. I'm happy to leave the decision over abstract base class to @kring.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 3, 2014

Thanks @chris-cooper. @kring this is all you to merge. I suggest a default implementation for getTileDataAvailable unless there is some JavaScript reason not to.

* @param {Number} x The X coordinate of the tile for which to request geometry.
* @param {Number} y The Y coordinate of the tile for which to request geometry.
* @param {Number} level The level of the tile for which to request geometry.
* @returns {Number} Undefined if not supported, otherwise true or false.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be {Boolean}, right?

@chris-cooper
Copy link
Contributor Author

Well spotted @shunter. And now I've spelt amend wrong in the commit comment :-(

@kring
Copy link
Member

kring commented Sep 17, 2014

It's as if we want to document this function as optional so users know they need to check to see if the function exists or we need to start using inheritance of whatever form to avoid this.

I believe inheritance would have a performance cost we'd rather not pay. I agree it should be documented as optional, though.

Rather than documenting the new function as optional, I added a deprecationWarning when it is missing. The idea is that the function is required, but we won't roll out that breaking change immediately. If this seems reasonable to everyone, I'll write an issue to remove the defined check and the deprecation warning in 3 releases, and then I'll merge this.

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 17, 2014

OK with me. Can you add it to a new Deprecated section in CHANGES.md?

kring added a commit that referenced this pull request Sep 18, 2014
getTileDataAvailable() handling for terrain providers
@kring kring merged commit 0a7d06f into master Sep 18, 2014
@kring kring deleted the tile-loading branch September 18, 2014 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants