homuler / MediaPipeUnityPlugin

Unity plugin to run MediaPipe
MIT License
1.8k stars 467 forks source link

[FaceLandmarkDetection] InvalidOperationException: Collection was modified; enumeration operation may not execute. #1253

Open emoto-yasushi opened 2 months ago

emoto-yasushi commented 2 months ago

Plugin Version or Commit ID

v1.4.4

Unity Version

2022.3.6f1

Your Host OS

Windows11 Home

Target Platform

UnityEditor, Windows Standalone

Target Device

No response

[Windows Only] Visual Studio C++ and Windows SDK Version

Visual Studio 2022

[Linux Only] GCC/G++ and GLIBC Version

No response

[Android Only] Android Build Tools and NDK Version

No response

[iOS Only] XCode Version

No response

Build Command

Play the Unity game

Bug Description

During gameplay, an error message like the one below appears. However, the game itself does not stop running

InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.List`1+Enumerator[T].MoveNextRare () (at <eef08f56e2e042f1b3027eca477293d9>:0)
System.Collections.Generic.List`1+Enumerator[T].MoveNext () (at <eef08f56e2e042f1b3027eca477293d9>:0)
Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.PartitionLandmarkList[T] (System.Collections.Generic.IReadOnlyList`1[T] landmarks) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:176)
Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.Draw (System.Collections.Generic.IReadOnlyList`1[T] target, System.Boolean visualizeZ, System.Int32 circleVertices) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:116)
Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.Draw (Mediapipe.Tasks.Components.Containers.NormalizedLandmarks target, System.Boolean visualizeZ, System.Int32 circleVertices) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:127)
Mediapipe.Unity.MultiFaceLandmarkListAnnotation+<>c__DisplayClass18_0.<Draw>b__0 (Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation annotation, Mediapipe.Tasks.Components.Containers.NormalizedLandmarks target) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs:111)
Mediapipe.Unity.ListAnnotation`1[T].CallActionForAll[TArg] (System.Collections.Generic.IReadOnlyList`1[T] argumentList, System.Action`2[T1,T2] action) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ListAnnotation.cs:118)
Mediapipe.Unity.MultiFaceLandmarkListAnnotation.Draw (System.Collections.Generic.IReadOnlyList`1[T] targets, System.Boolean visualizeZ) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs:109)
Mediapipe.Unity.FaceLandmarkerResultAnnotationController.SyncNow () (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkerResultAnnotationController.cs:39)
Mediapipe.Unity.AnnotationController`1[T].LateUpdate () (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/AnnotationController.cs:74)

Steps to Reproduce the Bug

After importing the Unitypackage into Unity and opening the Samples/Scenes/Tasks/FaceLandmarkDetection scene, this issue sometimes occurs after playing the game for a while. It does not always happen. The time it takes for this to occur seems to be random and does not happen at a fixed interval every time. However, in most cases, this issue occurs within 10 minutes.

Log

InvalidOperationException: Collection was modified; enumeration operation may not execute. System.Collections.Generic.List1+Enumerator[T].MoveNextRare () (at <eef08f56e2e042f1b3027eca477293d9>:0) System.Collections.Generic.List1+Enumerator[T].MoveNext () (at :0) Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.PartitionLandmarkList[T] (System.Collections.Generic.IReadOnlyList1[T] landmarks) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:176) Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.Draw (System.Collections.Generic.IReadOnlyList1[T] target, System.Boolean visualizeZ, System.Int32 circleVertices) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:116) Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation.Draw (Mediapipe.Tasks.Components.Containers.NormalizedLandmarks target, System.Boolean visualizeZ, System.Int32 circleVertices) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkListWithIrisAnnotation.cs:127) Mediapipe.Unity.MultiFaceLandmarkListAnnotation+<>c__DisplayClass18_0.b__0 (Mediapipe.Unity.FaceLandmarkListWithIrisAnnotation annotation, Mediapipe.Tasks.Components.Containers.NormalizedLandmarks target) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs:111) Mediapipe.Unity.ListAnnotation1[T].CallActionForAll[TArg] (System.Collections.Generic.IReadOnlyList1[T] argumentList, System.Action2[T1,T2] action) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/ListAnnotation.cs:118) Mediapipe.Unity.MultiFaceLandmarkListAnnotation.Draw (System.Collections.Generic.IReadOnlyList1[T] targets, System.Boolean visualizeZ) (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/MultiFaceLandmarkListAnnotation.cs:109) Mediapipe.Unity.FaceLandmarkerResultAnnotationController.SyncNow () (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/FaceLandmarkerResultAnnotationController.cs:39) Mediapipe.Unity.AnnotationController`1[T].LateUpdate () (at ./Packages/com.github.homuler.mediapipe/Runtime/Scripts/Unity/Annotation/AnnotationController.cs:74)

Screenshot/Video

bug_mediapipe

Additional Context

No response

homuler commented 2 months ago

Maybe the same issue as https://github.com/homuler/MediaPipeUnityPlugin/issues/1223

homuler commented 2 months ago

The original issue was closed without being fixed, so it's fine to leave this one open.