Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Unity.Physics - Recursive type definition detected

Discussion in 'Physics for ECS' started by Enzi, Jun 10, 2019.

  1. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    958
    Hello!

    Is anyone familiar with this error?
    Code (CSharp):
    1. TypeLoadException: Recursive type definition detected
    2. Unity.Jobs.JobHandle:ScheduleBatchedJobsAndCompleteAll(Void*, Int32)
    3. Unity.Jobs.JobHandle:CompleteAll(NativeArray`1) (at C:/buildslave/unity/build/Runtime/Jobs/ScriptBindings/JobHandle.bindings.cs:49)
    4. Unity.Physics.Systems.EndFramePhysicsSystem:OnUpdate(JobHandle) (at Library/PackageCache/com.unity.physics@0.1.0-preview/Unity.Physics/ECS/Systems/EndFramePhysicsSystem.cs:43)
    5. Unity.Entities.JobComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ComponentSystem.cs:687)
    6. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ComponentSystem.cs:169)
    7. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ComponentSystemGroup.cs:369)
    8. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ComponentSystem.cs:570)
    9. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ComponentSystem.cs:169)
    10. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.0.12-preview.31/Unity.Entities/ScriptBehaviourUpdateOrder.cs:135)
    11.  
    In addition a single entry of "TypeLoadException: Recursive type definition detected" also shows up with no further info where it occured.

    I've some models with PhysicsShape and Body. Nothing special, unless the EntityConversion system does something I don't know about.

    I'm not sure how to debug this. Where can I get more info on this?

    Thanks!
     
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    I think it's related to some struct used in one of the jobs scheduled before Physics system.
    A recursive type definition is something like this:
    Code (CSharp):
    1. struct A
    2. {
    3.    public A FirstField; // direct use of the same type
    4.  
    5.    public B OtherField; // indirect use of the same type because of B.Field is same type.
    6. }
    7.  
    8. struct B
    9. {
    10.    public A Field;
    11. }
    So type has one of the fields of own type.
     
  3. Deleted User

    Deleted User

    Guest

    I have the same problem too. I don't reference other structs directly in my components. I only reference their entities.
    Did you manage to solve this issue?
     
  4. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    I have the same issue. Also, it seems like there are some race conditions since sometimes everything works just fine
    Code (CSharp):
    1. TypeLoadException: Recursive type definition detected
    2. Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
    3. Unity.Jobs.JobHandle:Complete()
    4. Unity.Entities.ComponentJobSafetyManager:CompleteAllJobsAndInvalidateArrays() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentJobManager.cs:140)
    5. Unity.Entities.EntityManager:CompleteAllJobs() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/EntityManagerSync.cs:19)
    6. Unity.Entities.EntityManager:BeforeStructuralChange() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/EntityManagerSync.cs:41)
    7. Unity.Entities.EntityManager:AddComponent(UnsafeMatchingArchetypePtrList, EntityQueryFilter, ComponentType) (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/EntityManagerChangeArchetype.cs:715)
    8. Unity.Entities.EntityManager:AddComponent(EntityQuery, ComponentType) (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/EntityManagerChangeArchetype.cs:84)
    9. Unity.Transforms.ParentSystem:UpdateNewParents() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Transforms/ParentSystem.cs:231)
    10. Unity.Transforms.ParentSystem:OnUpdate(JobHandle) (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Transforms/ParentSystem.cs:373)
    11. Unity.Entities.JobComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:924)
    12. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:284)
    13. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystemGroup.cs:602)
    14. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:800)
    15. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:284)
    16. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystemGroup.cs:602)
    17. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:800)
    18. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ComponentSystem.cs:284)
    19. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.1.1-preview/Unity.Entities/ScriptBehaviourUpdateOrder.cs:144)
    And then gets followed by
    Code (CSharp):
    1. IndexOutOfRangeException: Index 7077988 is out of range of '10' Length.
    2. Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <86888d7bf865490ca0c08194bf6338db>:0)
    3. Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <86888d7bf865490ca0c08194bf6338db>:0)
    4. Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <86888d7bf865490ca0c08194bf6338db>:0)
    5. Unity.Physics.BoundingVolumeHierarchy.Refit (Unity.Collections.NativeArray`1[T] aabbs, System.Int32 nodeStartIndex, System.Int32 nodeEndIndex) (at Library/PackageCache/com.unity.physics@0.2.0-preview/Unity.Physics/Collision/Geometry/BoundingVolumeHierarchyBuilder.cs:564)
    6. Unity.Physics.BoundingVolumeHierarchy+FinalizeTreeJob.Execute () (at Library/PackageCache/com.unity.physics@0.2.0-preview/Unity.Physics/Collision/Geometry/BoundingVolumeHierarchyBuilder.cs:842)
    7. Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <86888d7bf865490ca0c08194bf6338db>:0)
    8.  
     
  5. bdero

    bdero

    Joined:
    Feb 7, 2016
    Posts:
    2
    I'm pretty sure I hit a close variation of this issue when running systems using the latest Unity Physics preview as of writing as well. I didn't find it reported anywhere, so I submitted it as a bug with a minimally reproducible project here.

    Unity Editor: 2019.3.0b6
    Unity Physics: preview - 0.2.4
    Entities: preview - 0.1.1
    Jobs: preview - 0.1.1
     
    Tony_Max likes this.
  6. lazalong

    lazalong

    Joined:
    Oct 13, 2009
    Posts:
    139
    Same issue.

    If I remove the Unity Physics: preview - 0.2.4 the error dissapear. So I am pretty sure that it is due to this version.
    Need to find if putting an initialisation order will solve this.
     
  7. Radu392

    Radu392

    Joined:
    Jan 6, 2016
    Posts:
    210
    I have this issue without using physics. It happens after Unity compiles my modified code and only maybe once or twice a day. Console gets spammed with about 20 of these messages without any stacktrace. Once I hit play though everything works fine.
     
  8. Sibz9000

    Sibz9000

    Joined:
    Feb 24, 2018
    Posts:
    149
    I think I solved this by renaming one of my components - LinearVelocity (to MyLinearVelocity). Odd because I have all my stuff in it's own namespace.

    Edit: Still getting this error after above change, but less frequently. I think the renaming didn't solve it at all, just coincidence the frequency of the issue reduced at the time.
     
    Last edited: Nov 4, 2019
  9. Sibz9000

    Sibz9000

    Joined:
    Feb 24, 2018
    Posts:
    149
    Found a more descriptive error:
    Code (csharp):
    1. TypeLoadException: Recursive type definition detected
    2. Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
    3. Unity.Jobs.JobHandle:Complete()
    4. Unity.Entities.ComponentJobSafetyManager:CompleteReadAndWriteDependencyNoChecks(Int32) (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentJobManager.cs:374)
    5. Unity.Entities.ComponentJobSafetyManager:CompleteDependenciesNoChecks(Int32*, Int32, Int32*, Int32) (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentJobManager.cs:200)
    6. Unity.Entities.ComponentSystemBase:CompleteDependencyInternal() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:730)
    7. Unity.Entities.ComponentSystemBase:AddReaderWriters(EntityQuery) (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:639)
    8. Unity.Entities.ComponentSystemBase:GetEntityQueryInternal(ComponentType*, Int32) (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:653)
    9. Unity.Entities.ComponentSystemBase:HasSingleton() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:580)
    10. Unity.Physics.Systems.StepPhysicsWorld:OnUpdate(JobHandle) (at Library/PackageCache/com.unity.physics@0.2.3-preview/Unity.Physics/ECS/Systems/StepPhysicsWorld.cs:93)
    11. Unity.Entities.JobComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:955)
    12. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:315)
    13. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystemGroup.cs:595)
    14. Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:831)
    15. Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ComponentSystem.cs:315)
    16. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.1.0-preview/Unity.Entities/ScriptBehaviourUpdateOrder.cs:144)
     
  10. Flipps

    Flipps

    Joined:
    Jul 30, 2019
    Posts:
    51
    Anyone solved this problem?
    Still have this exception from time to time.
    When i uninstall Unity physics it does not happen again. Also does not occur when there are no physic objects in the scene.
     
  11. Sibz9000

    Sibz9000

    Joined:
    Feb 24, 2018
    Posts:
    149
    I have a bug in the system for this, they wanted a video, however I haven't had the issue re-occur since they asked. If you can post one that might help them.
     
  12. Sibz9000

    Sibz9000

    Joined:
    Feb 24, 2018
    Posts:
    149
    filod likes this.
  13. Flipps

    Flipps

    Joined:
    Jul 30, 2019
    Posts:
    51
    Thanks, then we wait and hope they fixed it in the next release :)
     
  14. Raffi2803

    Raffi2803

    Joined:
    Jan 26, 2020
    Posts:
    1
    I had the same problem. It occurs in a line from one simple error. I wrote the ":" I wrote the ":" instead of ";" at the end of the line.
     
  15. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    For us we had to cast an int to a float manually (even though Rider says the cast is redundant. Seems to be a compiler error?