The UpdateViewHierachy is raising an InvalidOperationException occasionally. The exact circumstances that cause this exception have not been identified...
This sort of exception usually happens when trying to remove items from a collection when it is being iterated over.
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator.MoveNext()
at ReactNative.UIManager.UIImplementation.UpdateViewHierarchy()
at ReactNative.UIManager.UIImplementation.DispatchViewUpdates(Int32 batchId)
at ReactNative.UIManager.UIManagerModule.OnBatchComplete()
at ReactNative.Bridge.NativeModuleRegistry.OnBatchComplete()
at ReactNative.Bridge.ReactInstance.NativeModulesReactCallback.OnBatchComplete()
at ReactNative.Bridge.ReactBridge.<>c__DisplayClass9_0.b__0()
at ReactNative.Bridge.Queue.MessageQueueThread.AnyBackgroundMessageQueueThread.<>c__DisplayClass5_0.b__0()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at ReactNative.DevSupport.DisabledDevSupportManager.<>c__DisplayClass18_0.b__0()
at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at ReactNative.Bridge.DispatcherHelpers.d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
I actually think its a problem with the root view being added to the collection. Looking at the code, the operation to add a root view tag to the ShadowNodeRegistry occurs on the UI thread, while all other operations occur on the layout thread.
I think this is actually a dupe of https://github.com/Microsoft/react-native-windows/issues/266.