The following content comes from a translator, please forgive any inaccuracies. Thank you very much. Title
SceneLayer throws "Please use getSymbolAsync if valueExpression is used" when swapping a UniqueValueRenderer with valueExpression at runtime
Environment
Description
When a UniqueValueRenderer with valueExpression is passed to the renderer property inside the constructor of SceneLayer, the layer loads and renders correctly with no console errors.
However, once the layer has already finished loading and is being rendered in the view, if I swap the renderer at runtime (i.e. sceneLayer.renderer = newUniqueValueRenderer, where newUniqueValueRenderer also uses valueExpression), the console keeps throwing:
[esri.renderers.UniqueValueRenderer] #getSymbol() Please use getSymbolAsync if valueExpression is used
Steps to reproduce
Expected behavior
Whether a valueExpression-based renderer is passed at construction time or assigned at runtime after the layer is already loaded, it should consistently be resolved through the async getSymbolAsync() path internally. There should be no code path calling the synchronous getSymbol(), and no console errors.
Actual behavior
Visually, the rendering still appears correct in most cases, but the sheer volume of console errors makes this unacceptable for a production app.
Current workaround
Instead of hot-swapping the renderer property, we now remove the layer from the map (view.map.remove(layer)) and recreate a brand-new SceneLayer instance with the new valueExpression-based renderer passed in the constructor, then add it back to the map. This avoids the error, but it means re-fetching and re-decoding all tiles every time the renderer changes, which is not ideal for performance.
Ask
Could the team please confirm:
Hi @lingyanmao, thanks for posting your question here. Unfortunately, my first thought is, can you reproduce this issue with the latest version? We're currently at version 5.1.
https://developers.arcgis.com/javascript/latest/release-notes/