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

Add console errors when a tileset contains unsupported extensions #9586

Merged
merged 11 commits into from
Jun 2, 2021

Conversation

srothst1
Copy link
Contributor

@srothst1 srothst1 commented Jun 2, 2021

Fixes #9552

There is no _extensionsRequired property in Cesium3DTileset so this pull request uses the _extensions property - should we add _extensionsRequired?

Updated CONTRIBUTORS.md.

@ptrgags

@cesium-concierge
Copy link

Thanks for the pull request @srothst1!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

Copy link
Contributor

@ptrgags ptrgags left a comment

Choose a reason for hiding this comment

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

@srothst1 Looked over the code, just a few small changes needed.

Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
Source/Scene/Cesium3DTileset.js Show resolved Hide resolved
@@ -1751,6 +1751,8 @@ Cesium3DTileset.prototype.loadTileset = function (
throw new RuntimeError("The tileset must be 3D Tiles version 0.0 or 1.0.");
}

Cesium3DTileset.checkSupportedExtensions(this._extensions);
Copy link
Contributor

Choose a reason for hiding this comment

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

A few things here:

  1. this._extensions is not yet initialized (see lines 965 and 974) at this point in the code, as loadTileset() gets called first. Use tilesetJson.extensionsRequired instead.
  2. Also it would be good to check if (defined(tilesetJson.extensionsRequired)) { /* check supported extensions */ } just in case the array is undefined (which will be the case most of the time)
  3. To answer your question about whether we need to add this._extensionsRequired, I don't think we need it, as this is the only place the required extensions list is used.

@srothst1
Copy link
Contributor Author

srothst1 commented Jun 2, 2021

@ptrgags I believe that I have implemented all of the changes - let me know what you think!

Copy link
Contributor

@ptrgags ptrgags left a comment

Choose a reason for hiding this comment

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

@srothst1 almost there, just two more little things.

I also put together a local Sandcastle to double check the three main cases:

  1. A tileset with no extensions loads
  2. A tileset with a supported extension loads
  3. A tileset with an unsupported extension throws an error which will cause the readyPromise to reject

If you want to try this yourself, you have to make sure Cesium is running first before clicking the link above:

npm install
npm run build
npm start

(this Build Guide)

Source/Scene/Cesium3DTileset.js Outdated Show resolved Hide resolved
Comment on lines 2830 to 2831
for (var extension in extensionsRequired) {
if (extensionsRequired.hasOwnProperty(extension)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

😮 My bad, I had forgotten that extensionsRequired is an array, not an object. This should be changed to a for (var i = 0; i < extensionsRequired.length; i++) loop instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think ModelUtility.js has the same mistake but works accidentally. @srothst1 could you open a PR to fix that as well?

@srothst1
Copy link
Contributor Author

srothst1 commented Jun 2, 2021

@ptrgags just added an update to Cesium3DTileset.js

Comment on lines 2831 to 2832
if (!Cesium3DTileset.supportedExtensions[extensionsRequired[i]]) {
throw new RuntimeError("Unsupported 3D Tiles Extension: " + extension);
Copy link
Contributor

Choose a reason for hiding this comment

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

One last tiny thing, extension here is undefined in the error message, so it ends up throwing a ReferenceError.

Fix this and I'll merge

@ptrgags
Copy link
Contributor

ptrgags commented Jun 2, 2021

@srothst1 changes look good, I'll merge once Travis passes.

@ptrgags ptrgags merged commit b376a0b into master Jun 2, 2021
@ptrgags ptrgags deleted the handle-unsupported-extensions branch June 2, 2021 18:57
@ptrgags
Copy link
Contributor

ptrgags commented Jun 2, 2021

Merged! thanks @srothst1!

@lilleyse
Copy link
Contributor

lilleyse commented Jun 3, 2021

I pushed a small tweak to CHANGES.md: "3D tiles" -> "3D Tiles"

31df31e

Thanks for the PR @srothst1!

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.

Add console warnings when a tileset contains unsupported extensions
4 participants