Skip to content

InvalidOperationException in MixedRealityToolkitFiles when editor was reloading scripts #5945

@keveleigh

Description

@keveleigh

Describe the bug

Specifically, after I switched branches and Unity was reloading, I saw the following print out in the editor:

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.Dictionary`2+Enumerator[TKey,TValue].MoveNext () (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
Microsoft.MixedReality.Toolkit.Utilities.Editor.MixedRealityToolkitFiles.TryUnregisterModuleFolder (System.String folder) (at Assets/MixedRealityToolkit/Utilities/Editor/Setup/MixedRealityToolkitFiles.cs:220)
Microsoft.MixedReality.Toolkit.Utilities.Editor.MixedRealityToolkitFiles+AssetPostprocessor.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Assets/MixedRealityToolkit/Utilities/Editor/Setup/MixedRealityToolkitFiles.cs:91)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:141)

To reproduce

I've seen this a few times, so here are what I think the most likely repro steps are:

  1. Switch branches while the project is open in Unity (or maybe even just edit a script so Unity reloads something) (it might be specific to a folder being created / removed)
  2. Re-focus the editor
  3. Allow it to reload assets
  4. See exception in console

Screenshots

image

Your Setup (please complete the following information)

  • Unity Version [e.g. 2018.3.11f1]: 2018.4.6f1
  • MRTK Version [e.g. v2.0]: mrtk_development

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions