ArcGISRuntime hangs when reusing a CompositeSymbol (Repro sample included)

175
2
06-22-2018 12:13 PM
RichardMcGough
New Contributor II

We create a CompositeSymbol using two symbols, a SimpleMarkerSymbol for the background and a PictureMarkerSymbol created from a RuntimeImage as follows:

SimpleMarkerSymbol background = new SimpleMarkerSymbol() { Color = this.BackgroundColor, Style = SimpleMarkerSymbolStyle.Circle, Size = this.Size };


ImageSource img = new BitmapImage(new Uri(@"pack://application:,," + this.IconPath, UriKind.RelativeOrAbsolute));
RuntimeImage runtimeimage = await img.ToRuntimeImageAsync();

PictureMarkerSymbol picsymbol = new PictureMarkerSymbol(runtimeimage) { Height = this.Size, Width = this.Size };

CompositeSymbol composite = new CompositeSymbol();
composite.Symbols.Add(background);
composite.Symbols.Add(picsymbol);

We save this symbol in a dictionary so we can reuse it rather than creating a new one each time it is needed. There appears to be some kind of race condition that causes the ArcGISRuntime to hang about 33% of the time we run the attached sample application. Pausing the Debugger during the hang shows that the application has stopped after the sample code attempts to add the graphic to the GraphicsOverlay:

this.m_Overlay.Graphics.Add(cg);

The call stack shows that the execution stopped in this method:

 

Esri.ArcGISRuntime.dll!RuntimeCoreNet.GeneratedWrapper.CoreVector.Insert( ....)

Call stack

When running the attached sample, you must restart it between tests. It usually only takes two or three attempts before it hangs. 

Is there something wrong with this approach to caching CompositeImages, or is it a bug in the ArcGISRuntime? Please let me know if there is a better approach or a workaround. Caching the images is important because we use thousands of them they take a lot of overhead to create (in our real app the background is a more complicated bitmap).

Any help would be greatly appreciated. 

Thanks!

Reply
0 Kudos
2 Replies
RichardMcGough
New Contributor II

I have updated the repro project to use the latest 100.3 ArcGISRuntime and problem persists.

I also updated it so you don't need to restart between tests. Just hit the "Start Test" repeatedly button until the app freezes. It usually takes only a few clicks before the problem manifests. 

Any help would be much appreciated. 

Reply
0 Kudos
CharlesRoberts1
New Contributor III

I was not able to find a solution, but I did make the following observations:

  1. The problem is not CompositeSymbol, it is PictureMarkerSymbol. Using only PictureMarkerSymbol still demonstrates the issue
  2. If you do not clear the cache, it works without hanging, and this is probably what you want to do anyway, at least until (or even if)  the cache grows too large
  3. Caching just the RuntimeImage, but recreating the symbol for each graphic each time also works correctly
  4. Adding Trace output statements in the loop (slowing it down) makes it work. Not a solution or workaround but perhaps a clue as the root cause of the problem.