Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Bug Rival - The container does not support parallel writing. Please use a more suitable container type

Discussion in 'Entity Component System' started by dolanmiu, Oct 5, 2022.

  1. dolanmiu

    dolanmiu

    Joined:
    Jun 16, 2016
    Posts:
    4
    I am using the Rival Character Controller, and I am getting the following error in my scene from simply adding the First Person Character and Player and following the guide in the docs:

    https://philsa.github.io/rival-doc/StandardCharacters/stdcharacters-firstperson.html

    Potential Bug in the Rival DOTS Character Controller?


    Code (CSharp):
    1. InvalidOperationException: FirstPersonCharacterMovementJob.JobData.CollisionWorld.EntityBodyIndexMap is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
    2. Unity.Entities.JobEntityBatchIndexExtensions.FinalizeScheduleChecked (System.Boolean isParallel, Unity.Jobs.JobHandle prefilterHandle, System.Void* prefilterData, Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& scheduleParams, System.Boolean& executed, Unity.Jobs.JobHandle& result) (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/IJobEntityBatchWithIndex.cs:890)
    3. Unity.Entities.JobEntityBatchIndexExtensions.ScheduleInternal[T] (T& jobData, Unity.Entities.EntityQuery query, Unity.Jobs.JobHandle dependsOn, Unity.Jobs.LowLevel.Unsafe.ScheduleMode mode, System.Boolean isParallel) (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/IJobEntityBatchWithIndex.cs:665)
    4. Unity.Entities.JobEntityBatchIndexExtensions.ScheduleParallel[T] (T jobData, Unity.Entities.EntityQuery query, Unity.Jobs.JobHandle dependsOn) (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/IJobEntityBatchWithIndex.cs:272)
    5. FirstPersonCharacterMovementSystem.OnUpdate () (at Assets/Rival_StandardCharacters/FirstPerson/Scripts/FirstPersonCharacterMovementSystem.cs:166)
    6. Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/SystemBase.cs:409)
    7. Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
    8. UnityEngine.Debug:LogException(Exception)
    9. Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/Stubs/Unity/Debug.cs:19)
    10. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:588)
    11. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:523)
    12. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
    13. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
    14. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:529)
    15. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
    16. Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
    17. Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:523)
    18. Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
    19. Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ScriptBehaviourUpdateOrder.cs:426)
     
  2. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    48
    Can you validate that the "CollisionWorld" in the "FirstPersonCharacterMovementJob" has a "[ReadOnly]" attribute over it, as highlighted here?


    I've re-downloaded the asset from the store and the attribute is there by default
     
  3. dolanmiu

    dolanmiu

    Joined:
    Jun 16, 2016
    Posts:
    4
    Yes, CollisionWorld does have [ReadOnly] applied. Screenshot attached

    asdfasdf.png
     
  4. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    48
    Which unity version are you using? Just tried this in a new 2021.3.8 project, with Entities 0.51.1-preview.21, and haven't been able to repro the issue so far.

    I might have 2 suggestions:
    1. you could try to right-click any file/folder in your Project window, and select "Reimport All". If anything went wrong with the package cache for whatever reason, this might fix it (this is like deleting the Library folder and reopening the project)
    2. you could try deleting your standard characters folder and try to re-extract the "StandardCharacter_FirstPerson" unitypackage into your project.

    If you want to, sending me a repro project could also be helpful
     
    Last edited: Oct 5, 2022
  5. dolanmiu

    dolanmiu

    Joined:
    Jun 16, 2016
    Posts:
    4
    Figured out the problem

    I have a file in my project called `Readonly.cs`, which has the following contents:

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. public class ReadOnlyAttribute : PropertyAttribute
    5. {
    6. }
    7.  
    8. [CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
    9. public class ReadOnlyDrawer : PropertyDrawer
    10. {
    11.     public override float GetPropertyHeight(SerializedProperty property,
    12.                                             GUIContent label)
    13.     {
    14.         return EditorGUI.GetPropertyHeight(property, label, true);
    15.     }
    16.  
    17.     public override void OnGUI(Rect position,
    18.                                SerializedProperty property,
    19.                                GUIContent label)
    20.     {
    21.         GUI.enabled = false;
    22.         EditorGUI.PropertyField(position, property, label, true);
    23.         GUI.enabled = true;
    24.     }
    25. }
    It seems like Rival does not like this, and causes issues. I was trying to create a custom PropertyDrawer in the past, from using an answer from here:

    https://answers.unity.com/questions/489942/how-to-make-a-readonly-property-in-inspector.html

    https://docs.unity3d.com/ScriptReference/PropertyDrawer.html

    Reproduction steps:

    Reproduction steps is simply adding this Readonly.cs file into your project.
     
    Last edited: Oct 5, 2022
    visualjoy and philsa-unity like this.
  6. philsa-unity

    philsa-unity

    Unity Technologies

    Joined:
    Aug 23, 2022
    Posts:
    48
    I see, so the issue is that when not specifying which specific [ReadOnly] attribute should be used, it defaults to yours instead of the Unity.Collections one

    A solution would be to put your ReadOnly attribute in a namespace, so it doesn't conflict with the existing one. The Unity.Collections [ReadOnly] will be used everywhere in DOTS projects, so it's better to change yours instead of writing [Unity.Collections.ReadOnly] everywhere

    Code (CSharp):
    1. namespace MyNamespace
    2. {
    3.     public class ReadOnlyAttribute : PropertyAttribute
    4.     {
    5.     }
    6. }
     
    Last edited: Oct 5, 2022
    dolanmiu likes this.
  7. dolanmiu

    dolanmiu

    Joined:
    Jun 16, 2016
    Posts:
    4
    Precisely that yes. I suppose a good practice is to always namespace your own code, to avoid clashes?
     
    philsa-unity likes this.