Synchronously clear route alternatives source to minimize flash #5688
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.
Description
Attempts to improve #5687.
The problem is that when an alternative route changes, we clear its
GeoJsonSourcedata and reset the expression to remove the vanishing portion. However, due to the async nature of the renderer, the expression that removes the vanishing portion (making all layer visible) is applied faster then the call that clears the source, briefly uncovering the whole geometry.One factor here is the fact that by default Android Maps SDK parses the geometries on a worker thread, even if the geometry is empty, which unnecessarily adds a delay of context switching to the equation. In the current state of the branch I'm skipping the async parsing and setting the empty source directly.
Before:
device-2022-04-04-140840.mp4
After:
device-2022-04-11-133909.mp4
This by no means resolves the problem but does seem to improve it ever so slightly. It looks like we'd need an API that would allow us to batch both source and layer property updates together, similarly to existing
setStyleSourcePropertiesandsetStyleLayerProperties, something likesetStyleProperties([{source ID, property}, {layer ID, property}]).Opening this just as a POC, we can consider merging but don't really need to as we'd have to resolve the root cause anyway.
cc @cafesilencio @zmiao @alexshalamov @tobrun @kiryldz