fix: source with transform reloads #789
Open
+2
−1
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.
Hey team,
I found an issue when using a
source
with atransform
function. The source will be reloaded whenever thescene.updateConfig()
is called. This impacted the performance a lot as my project uses a bundled source with thetransform
for multiple tiled layers.The bug is because the
this.last_config_sources
in the comparison condition is mutated by the in-placecompileFunctionStrings
function in the following logic. It's no longer the serialised object with "original function strings", but a deserialised object with "compiled real functions", and the real functions are ignored byJSON.stringify
. so there will always be differences between the new and last source config which reloads the source.https://github.com/wangxingkai/tangram/blob/bf7ff0f5e90da963e18df709d8f041c93fd94836/src/scene/scene_worker.js#L117
https://github.com/wangxingkai/tangram/blob/bf7ff0f5e90da963e18df709d8f041c93fd94836/src/scene/scene_worker.js#L123
if add a
transform
function in the demo code, the bug can be reproduced:https://github.com/wangxingkai/tangram/blob/7baed5ea035938bc9de4116ff9a1ce039ddebb47/demos/scene.yaml#L110
Before fix:
https://user-images.githubusercontent.com/6101654/152491059-5f31a474-a6a0-48a0-a283-39f9e5a7d474.mov
After fix:
https://user-images.githubusercontent.com/6101654/152491220-d8152c74-56d6-421a-96d1-f4b2142f0685.mov