-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 clipping planes crash when adding plane to empty collection #7168
Conversation
Thanks for the pull request @OmarShehata!
Reviewers, don't forget to make sure that:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
This was true in |
Thanks for the additional test case @likangning93 . Looks like the problem was a little more subtle. There's a lot of assumptions in the clipping plane code that there will always be at least 1 plane. So, it's not that it crashes when you add planes and remove them all, it will always crash if there aren't any planes, it's just that I made some broader changes now, that clipping planes should be only be applied if there's at least one plane. I think this is a better solution than passing an empty texture and running the shader. Would you like to review this Gary? |
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.
Just one note that doesn't actually need changes, otherwise this looks good. Can you update CHANGES.md?
@@ -145,7 +145,7 @@ define([ | |||
(imageryCutoutFlag << 21); | |||
|
|||
var currentClippingShaderState = 0; | |||
if (defined(clippingPlanes)) { | |||
if (defined(clippingPlanes) && clippingPlanes.length > 0) { |
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 think the clippingPlanes.length > 0
check is covered in GlobeSurfaceTileProvider.computeTileVisibility
by a check for if the globe surface tile intersects any clipping planes. We also do this for 3D Tiles, so tiles in a tileset that aren't touched by any clipping planes won't have injected clipping code. This change doesn't seem like it will hurt beyond being a little inconsistent with what's happening elsewhere, so no change needed, just wanted you to be aware.
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 think it might not be needed here, but Model was crashing because it considered clipping planes enabled even if there weren't any, so I added this check everywhere else to be consistent.
Should be ready now @likangning93 ! |
CI still refusing to run tests for unknown reasons, but they pass locally using the same commands and I don't see anything in here that would be causing the CI failure. I'm going to merge, noted in #7193. |
This fixes #7167.
The problem was, if there are no clipping planes added, the width is 0, and height is 1/width, hence the
NaN
crash.I fixed it by only creating the texture when it needs to. I also added 2 tests that would have caught this/to make sure it doesn't happen again.
@lilleyse can you review? Here are all your Sandcastle links as localhost links to confirm it doesn't crash now:
Model
3D Tiles
Terrain
Point clouds