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

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?

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.
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)
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)
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)
FirstPersonCharacterMovementSystem.OnUpdate () (at Assets/Rival_StandardCharacters/FirstPerson/Scripts/FirstPersonCharacterMovementSystem.cs:166)
Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/SystemBase.cs:409)
Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/Stubs/Unity/Debug.cs:19)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:588)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:523)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:529)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:583)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystemGroup.cs:523)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ComponentSystem.cs:114)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/ScriptBehaviourUpdateOrder.cs:426)

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

[quote=“philsa-unity”, post:2, topic: 896255]
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
[/quote]

Yes, CollisionWorld does have [ReadOnly] applied. Screenshot attached

8490749--1129562--asdfasdf.png

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:

  • 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)

  • 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

Figured out the problem

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

using UnityEditor;
using UnityEngine;

public class ReadOnlyAttribute : PropertyAttribute
{
}

[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
    public override float GetPropertyHeight(SerializedProperty property,
                                            GUIContent label)
    {
        return EditorGUI.GetPropertyHeight(property, label, true);
    }

    public override void OnGUI(Rect position,
                               SerializedProperty property,
                               GUIContent label)
    {
        GUI.enabled = false;
        EditorGUI.PropertyField(position, property, label, true);
        GUI.enabled = true;
    }
}

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.

2 Likes

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

namespace MyNamespace
{
    public class ReadOnlyAttribute : PropertyAttribute
    {
    }
}
1 Like

[quote=“philsa-unity”, post:6, topic: 896255]
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

namespace MyNamespace
{
    public class ReadOnlyAttribute : PropertyAttribute
    {
    }
}

[/quote]

Precisely that yes. I suppose a good practice is to always namespace your own code, to avoid clashes?

1 Like