Problems re-adding a GroupLayer to a map after it has been removed

3476
11
Jump to solution
05-17-2022 03:02 PM
Brandon-Ellis
New Contributor III

We are using ImageryLayers with AnimatedFlow vectors and a RasterStretchRenderer for color control in a GroupLayer (winds and wind speed) along with another  ImageryLayers with AnimatedFlow vectors (waves) to be displayed at different times. 

We use a button to toggle the two layers.  The winds are the default layer. 

When waves are activated, the winds layer group is removed and the waves layer is added (windWaveSwitch.JPG).

Toggling to waves works as expected/intended, but toggling to winds triggers an error (windWaveError.JPG).  Toggling the waves back on displays the waves and toggling back to the wind causes the error again.

The initial map.add happens when the layers are established (windWaveCode.JPG).  The windWave variable is string value of 'Wave' at that point in the code.

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

This issue will be fixed at 4.24 (will be released late June). You can try out the fix in our next version( <script src="https://js.arcgis.com/next/"></script>) and the fix will be available on next by Tuesday next week. 

Here is an updated codepen app to point to next. Please note that the fix is not in there until next Tuesday. https://codepen.io/U_B_U/pen/eYVWwvw?editors=100

Hope we can mark this issue as resolved. 

View solution in original post

11 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Can you set up a simple codepen app to showcase this? You can set it up using any layer as long as it shows the issue. Thanks.

0 Kudos
Brandon-Ellis
New Contributor III

The problem that we will run into is access to the services listed in the pen.  I am pretty sure that you will not be able to access the services used so you may need to add some ESRI services to replicate the issue.  The services are U/V NAVGEM data for winds with wind speed for the raster stretch color layer and U/V WW3 lvl 0 for the waves.  Hopefully there are already active services that will replicate these.

I used the services from your pen and the problem persists.

FlowRenderer layer switch test (codepen.io)

This pen replicates the issue with the necessary basic functionality, some of which is probably unnecessary but it has been added in the interest of best replicating the situation.  The control div shows up to the right of the visible screen, so you will need to scroll over to access it.  Toggling on the wave layer will add the waves then toggling the winds back on will fail to add the winds and produce the error in the previously attached image.

Here is the error from the codpen,

 

 

"[esri.views.2d.layers.imagery.ImageryView2D]" // [object Object] 
{
  "name": "TypeError",
  "details": {
    "stack": "TypeError: Cannot read properties of undefined (reading 'symbolize')\n    at z.A.symbolize (https://js.arcgis.com/4.23/esri/layers/support/RasterWorker.js:469:453)\n    at u.D._onInvokeMessage (https://js.arcgis.com/4.23/esri/core/workers/init.js:111:462)\n    at u._invoke (https://js.arcgis.com/4.23/esri/core/workers/init.js:105:336)\n    at u.D._process (https://js.arcgis.com/4.23/esri/core/workers/init.js:105:135)"
  },
  "message": "Cannot read properties of undefined (reading 'symbolize')"
}

 

 

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

@Brandon-Ellis this is a bug for ImageryLayer with RasterStretchRenderer. :(. I created an issue for this and will let you know once it is fixed. You can perhaps just toggle the visibility between the two layers in your app? If you need to add or remove layers at runtime, then you can remove the layer and destroy it... then add a new instance of the layer as shown in this app: https://codepen.io/U_B_U/pen/gOvWNKe?editors=1000

 

Brandon-Ellis
New Contributor III

Thanks for checking into the issue and confirming that it is a bug. 

We considered just toggling the visibility as a workaround, but were curious about the overhead on client machines.  Does the image FlowRenderer still compute the curvy vectors when .visible = false?  If not, toggling visibility will probably be the most efficient workaround to implement.

I do have another observation and question about the new implementation of FlowRenderer.  When toggling the visibility of the colored vectors, the RasterStretchRenderer layer flashes without the vector mask as if the layers within the group are turned off in a vectors first order.  This didn't happen in .22 when we started working with this ability instead of the animatedEnvironmentLayer library.  Can this be changed so that the raster stretch layer is turned off first in order to eliminate the flashing colors?

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

So I talked to the developer about toggling layer visibility. We do not run tracing while the layer is invisible. So it does not load, process or render the data while invisible. So yes toggling layer visibility will be the most efficient way.

The flashing happens only your app. I have not spend time debugging it though. If I pull out necessary code then the layer loads without flashing. https://codepen.io/U_B_U/pen/ExQXxma?editors=1001

Brandon-Ellis
New Contributor III

That's great news.  I will implement the workaround until the bug is fixed.

The pen you provided does not flash, but it also does not toggle the visibility of the group layer which is when the flashing occurs.  The function on line 19 in the JS toggles the visibility of the activeLayer (in this case the wind vector wind magnitude groupLayer) when the calciteIcon eye button is clicked.

FlowRenderer layer switch test (codepen.io)

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

This issue will be fixed at 4.24 (will be released late June). You can try out the fix in our next version( <script src="https://js.arcgis.com/next/"></script>) and the fix will be available on next by Tuesday next week. 

Here is an updated codepen app to point to next. Please note that the fix is not in there until next Tuesday. https://codepen.io/U_B_U/pen/eYVWwvw?editors=100

Hope we can mark this issue as resolved. 

Brandon-Ellis
New Contributor III

That's great news.  Thank you for assisting with the bug and the workaround.

Should I start a new thread for the flickering/flashing issue or are we able to continue here?

0 Kudos
Brandon-Ellis
New Contributor III

4.24 has resolved all of the issue that we were experiencing with FlowRenderer and its associated components.  We are preparing to move the new codebase into production.  Thank you for your assistance and a hearty 'Great Job!' to the whole team.  

0 Kudos