StopTraking() method throw an error InvalidOperationException: Collection was modified; enumeration operation may not execute

  • Issue category:VPS

  • Host machine & OS version: Windows

  • Issue Environment : Unity Remote /

  • ARDK version: 3.0

  • Unity version:2022.3.10

Description of the issue:

I’m having the next error when the method StopTracking() is called : InvalidOperationException: Collection was modified; enumeration operation may not execute. System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[TKey,TValue].MoveNext ()

Thisi is my code to start tracking . It works correctly :

public void LoadExperienceClicked()
{
var arLocations = _arLocationManager.ARLocations;
foreach (var arLocation in arLocations)
{
if (arLocation.Payload.ToBase64() == _gameManager.Destinations[_gameManager.IndexDestination].anchorPayload)
{
_arLocationManager.SetARLocations(arLocation);
_arLocationManager.StartTracking();
}
}
}

But in anywhere in the code where I call ARLocationManager.StopTracking() I have the same error:

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[TKey,TValue].MoveNext () (at <787acc3c9a4c471ba7d971300105af24>:0)
Niantic.Lightship.AR.LocationAR.ARLocationManager.StopTracking () (at ./Library/PackageCache/com.nianticlabs.lightship@1978137a58/Runtime/ARFoundation/Overrides/LocationAR/ARLocationManager.cs:256)