Fix crash with switching terrain provider and picking #6918
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6916
The crash was caused when things happen in the following order:
true
scene.render
is called, which queues commands, including the commands for the soon-to-be invalidatedGlobeSurfaceTile
s.QuadtreePrimitive
actually invalidates these tiles at the end of the frame.scene.pick
is called. It uses the same commands from the last render, which now includes commands for tiles that were freed at the end of the frame. This causes a crash because the vertex arrays for these commands have been destroyed.Moving
invalidateAllTiles
toframeStart
instead offrameEnd
prevents the commands for the invalid tiles from being added to the command queue.