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( ....)
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!
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.
I was not able to find a solution, but I did make the following observations: