Fix classification crash when toggling translucency #9447
Merged
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 #9421.
The idea behind this fix is that it is possible for the translucent command in
TranslucentTileClassification
to have a previously destroyed shader by the timegetDerivedCommand
is called fromexecuteTranslucentCommands
. One clue that supports this idea is that the crash only seems to happen when the translucency checkbox is turned on, and not off (see the Sandcastle). If the command is dirty by the timegetDerivedCommand
is called, the shader should be recreated instead of reusing the outdated one from when the tileset was opaque.I'm still not 100% sure when the command state gets messed up, but I believe the bug happens because:
dirty = true
.Scene
never checks whether the translucent commands are dirty (i.e. like it does with shadow maps inupdateDerivedCommands
), and the state is only visible from the loop over commands insideexecuteTranslucentCommands
. For this reason, checking for... || command.dirty
insideTranslucentTileClassification#getDerivedCommand
makes sense to me (as opposed to somewhere higher up likeScene
).dirty
command, the shader program can be pointing to an outdated shader that has already been destroyed.