#My pre.44 Issues
1 messages · Page 1 of 1 (latest)
1. Fail source gen if no using Unity.Entities
Temp\GeneratedCode\Shattered.AI\AISystem__System_13842432900.g.cs(13,42): error CS0246: The type or namespace name 'SystemState' could not be found (are you missing a using directive or an assembly reference?)
Repo
using BovineLabs.AI.Systems;
using BovineLabs.Game.Observations;
using Shattered.AI.Core;
using Shattered.Game.Actors.Components;
using Shattered.Game.Work;
using Unity.Transforms;
internal partial class AISystem : AISystemBase<AIContext>```
Fix
Add a dummy using Unity.Entities;
2. InputSystem InputActionReference on managed IComponentData breaks type manager initialization
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <83161767e3f34f4a9c1453ea3e22d1f1>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <83161767e3f34f4a9c1453ea3e22d1f1>:0)
Unity.Entities.TypeManager.ThrowOnNestedNativeContainerComponentData (System.Type type, System.Type baseType, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2798)
Unity.Entities.TypeManager.ThrowOnNestedNativeContainerComponentData (System.Type type, System.Type baseType, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2819)
Unity.Entities.TypeManager.ThrowOnNestedNativeContainerComponentData (System.Type type, System.Type baseType, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2797)
Unity.Entities.TypeManager.ThrowOnNestedNativeContainerComponentData (System.Type type, System.Type baseType, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2819)```
Unity.Entities.TypeManager.ThrowOnNestedNativeContainerComponentData (System.Type type, System.Type baseType, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2819) Unity.Entities.TypeManager.CheckIsAllowedAsManagedComponentData (System.Type type, System.String baseTypeDesc, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache, System.Boolean& hasNativeContainer) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2734) Unity.Entities.TypeManager.BuildComponentType (System.Type type, Unity.Entities.TypeIndex[] writeGroups, System.Collections.Generic.Dictionary`2[TKey,TValue] hashCache, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2896) Unity.Entities.TypeManager.BuildComponentType (System.Type type, System.Collections.Generic.Dictionary`2[TKey,TValue] hashCache, System.Collections.Generic.Dictionary`2[TKey,TValue] nestedContainerCache) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2836) Unity.Entities.TypeManager.AddAllComponentTypes (System.Type[] componentTypes, System.Int32 startTypeIndex, System.Collections.Generic.Dictionary`2[TKey,TValue] writeGroupByType, System.Collections.Generic.Dictionary`2[TKey,TValue] descendantCountByType) (at ./Library/PackageCache/com.unity.entities@1.0.0-pre.44/Unity.Entities/Types/TypeManager.cs:2610)
Repo
[Serializable]
public class InGameInputConfig : IComponentData
{
public InputActionReference BuildState;
public InputActionReference Quit;
}```
Fix
None 😦
@karmic depot i think ThrowOnNestedNativeContainerComponentData needs to check that it's not class icomponentdata, because you can't schedule against that anyway
3. Aspects seem completely broken
public readonly partial struct TestAspect : IAspect
{
private readonly RefRO<BLDebug> Test;
}```
```Unity.Entities.SourceGen.AspectGenerator\Unity.Entities.SourceGen.Aspect.AspectGenerator\TestAspect__Aspect_9250899270.g.cs(36,99): error CS0246: The type or namespace name 'ComponentType' could not be found (are you missing a using directive or an assembly reference?)```
ThrowOnNestedNativeContainerComponentData
What do you know - I have a ticket in the current sprint to look at exactly this issue.
i suppose maybe we should add an attribute saying leave me alone i know what i'm doing in that department, also
Alternatively you can use a pointer to the nested container, and use the attribute which lets you do that
my aspect seems to generate with no usings
Repo
namespace BovineLabs.Core
{
using Unity.Entities;
public readonly partial struct TestAspect : IAspect
{
public readonly RefRO<BLDebug> Test;
}
}```
# Workaround
```cs
using Unity.Entities;
namespace BovineLabs.Core
{
public readonly partial struct TestAspect : IAspect
{
public readonly RefRO<BLDebug> Test;
}
}
oh @unique depot i thought you had fixed this! I got you again on the same issue 😄
generates with the using when swapped as above
You're killing me here
```InvalidOperationException: The ComponentLookup<BovineLabs.NavMesh.Data.NavMeshRuntimeData> NavMeshChangeJob.NavMeshRuntimeData can not be accessed. Nested native containers are illegal in jobs.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <05041d4f5ec242309356a6b3b04452e6>:0)```
Marking this not an error I'll work around it
unless something has drastically changed passing in a regular struct with a collection of native containers works fine for the safety system
just for full completeness
{
public DTNavMesh NavMesh;
public EdgeCollection Edges;```
``` public unsafe struct DTNavMesh : IDisposable, IEquatable<DTNavMesh>
{
private IntPtr value;```
``` public readonly unsafe struct EdgeCollection : IDisposable
{
private readonly Allocator allocator;
private readonly int edgesLength;
private readonly Edges* edges;
private readonly float3 boundsMin;
private readonly float ts;
private readonly int tilesX;
i don't think this last one is a bug
componentlookup is itself a nativecontainer
the safety system cannot handle scheduling jobs against nested native containers
it can handle using nested native containers on the main thread, though
what nested container? i'm getting the native array on the main thread
as i said, the component lookup is itself a native container, and it contains your component, which contains a native container
and you're scheduling a job against the componentlookup
{
var drawer = SystemAPI.GetSingleton<DrawSystem.Singleton>().CreateDrawer<NavMeshDrawEdgeSystem>();
var navMeshWorlds = SystemAPI.GetSingleton<NavMeshRuntimeData>().NavMeshWorlds;
state.Dependency = new DrawNavMeshJob { NavMeshWorlds = navMeshWorlds, Drawer = drawer }.Schedule(state.Dependency);
}```
this worked fine in pre.15
yeah but it was a race condition
this basically means you can't put native containers on components at all anymore no?
it means you can't schedule jobs against components with native containers
which was indeed the idea
how is this not safe though? the system has a dependency on this container component
if i'm only reading from it
it's marked as readonly on the struct
{
[ReadOnly]
internal NativeArray<NavMeshWorld> Worlds;```
if i don't mark this read only
i get a safety issue
for scheduling
(even in a non parallel job)
this is already being used by xyz
do you get a safety issue from that particular schedule?
i believe the situation is as follows: the job is scheduled against the componentlookup, which has an AtomicSafetyHandle on it. the job safety system diddles that handle when you schedule the job to do its job safety things. it does not look inside the componentlookup to see if there are any native containers inside it that need their handles diddled also
so if you were to write to the inside native container by itself while the job was going on, it would not stop you
the container is only used via access to the component
yeah but the safety system doesn't know that
but an, incorrect in my use case, static analysis has broken my entire project
may i suggest an UnsafeList
i'm going to do that
but i like the fact that if someone tried to write to this container in a job
it would error
so
you still get the safety in terms of access to the component
but unfortunately they could talk to the unsafelist without your knowledge and we couldn't help you there
if have 2 jobs that reference the same native array
and the first job reads to it and the 2nd job writes to it
and i don't setup a correct dependency between the 2 jobs
i get an error on the second job
yep. that said, to make this work, we would have to look inside every native container scanning for safety handles, and it's hard to see how that would be that fast
you could also make an unsafelist or a pointer that just points to the existing nativearray
and then whenever you talk about it outside of the componentlookup, you would use it via the nativearray
var dependency2 = new Job2 {container = array}.Schedule(dependencyY);```
I have safety here even if these jobs are scheduled in different systems
it's going to yell at me
it's true
that's what i was relying on
out of curiosity
what if you just passed the nativearray itself to DrawNavMeshJob, rather than passing the component
would that ruin everything?
does the nativearray itself change ever?
or just its contents?
the native container never changes once initialized
its created in OnStartRunning and never changed
sounds promising to just pass the container itself then
i was just trying to wrap implementation is all from users
but it really not a big deal
{
[ReadOnly]
internal NativeArray<NavMeshWorld> Worlds;
public int WorldsLength => this.Worlds.Length;
/// <summary> Gets the navigation world associated with an agent. </summary>
/// <param name="agent"> The agent. </param>
public NavMeshWorld this[byte agent] => this.Worlds[agent];
internal void Dispose()
{
for (var i = 0; i < this.Worlds.Length; i++)
{
if (this.Worlds[i].IsCreated)
{
this.Worlds[i].Dispose();
}
}
this.Worlds.Dispose();
}
}```
this is the entire thing
they're just indexing/getting length anyway
so apart from doing something completely dumb it doesn't matter
it's more from an old setup
👍 sorry we couldn't make it work in this case; we may revisit it in the future if we discover we can do those checks fast enough
if it works via just passing the native array it'll be fine
5. [WithChangeFilter] and writing to component causes duplicate components in IJobEntity
EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name Cluster. Queries can only contain a single component of a given type in a filter.
[BurstCompile]
[WithAll(typeof(ClusterConnection), typeof(EntityDestroy))]
[WithChangeFilter(typeof(Cluster))]
private partial struct ClusterInitializeJob : IJobEntity, IJobEntityChunkBeginEnd
{
private void Execute(Entity entity, ref Cluster cluster, in TransformAspect transform)
{```
__query_1355768233_0 = new Unity.Entities.EntityQueryBuilder(Unity.Collections.Allocator.Temp).WithAllRW<global::BovineLabs.Fracture.Data.Cluster>().WithAll<global::BovineLabs.Fracture.Data.ClusterConnection>().WithAll<global::BovineLabs.Core.Destroy.EntityDestroy>().WithAll<global::BovineLabs.Fracture.Data.Cluster>().WithAspect<global::Unity.Transforms.TransformAspect>().Build(ref state);
the query that was generated added both a RW and read version
OH issue 4
i mismatched the error to the actual problem
i do in fact have a
public ComponentLookup<NavMeshRuntimeData> NavMeshRuntimeData;```
but i was only using it for
{
return;
}```
change filtering
i never actually read from it
i was so confused why you were talking about componentlookup when that was the actual error i posted >_>
ok yeah I'll consider this not an error and try find a workaround
public unsafe struct DidChangeLookup
{
[NativeDisableUnsafePtrRestriction]
private readonly EntityDataAccess* access;
private LookupCache cache;
internal DidChangeLookup(EntityDataAccess* access)
{
this.access = access;
this.cache = default;
}
public bool DidChange(Entity entity, ComponentType componentType, uint version)
{
var ecs = this.access->EntityComponentStore;
var chunk = ecs->GetChunk(entity);
var archetype = chunk->Archetype;
if (Hint.Unlikely(archetype != this.cache.Archetype))
{
this.cache.Update(archetype, componentType.TypeIndex);
}
var typeIndexInArchetype = this.cache.IndexInArchetype;
if (typeIndexInArchetype == -1)
{
return false;
}
var chunkVersion = chunk->GetChangeVersion(typeIndexInArchetype);
return ChangeVersionUtility.DidChange(chunkVersion, version);
}
}```
this is why i like internal access!
well i'm in game, still need to fix #2 my input issue but everything else has been worked around
hopefully that's the end of my reports
I did yes, but if you've ever read any of the aspect generator you would see it's written completely different than all our other generators, so same goes for the nesting behavior, which i did not write for aspects :3
haha well I need someone to aim my anger* at! 😄
(* i have no anger)
Hehe, well thx for making me aware, I'll flag it internally 😅
i found 5. breaking a bit odd considering it worked previously (and doesn't involve me using weird namespaces)
Yeah.. that is interesting, I'll look into it. In the meantime if you wanna temporarily fix it, you can add the WithChangeFilter attributte to the ref Cluster cluster that should do the trick
wait that works?
i just removed the attribute and manually passed in a query with a filter on it
but that changes everything!
i might even prefer that way
Always has, guess I didn't write it clear enough in docs 😆 oh well, funnily enough, the attributes in IJE was one of the first things i worked on when i joined Unity, that and burning IJobForEach to smithereens :3
0x000001e3c1f8fec6 (Mono JIT Code) (wrapper managed-to-native) System.Buffer:InternalMemcpy (byte*,byte*,int)
0x000001e3c1f895cb (Mono JIT Code) System.Buffer:Memcpy (byte*,byte*,int)
0x000001e3c1f8fd93 (Mono JIT Code) string:memcpy (byte*,byte*,int)
0x000001e53f1198eb (Mono JIT Code) Unity.Entities.Editor.ComponentDataDiffer:CanWatch (Unity.Entities.ComponentType) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/ComponentDataDiffer.cs:308)
0x000001e53f118983 (Mono JIT Code) Unity.Entities.Editor.ComponentDataDiffer:.ctor (Unity.Entities.ComponentType) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/ComponentDataDiffer.cs:318)
0x000001e53f10887b (Mono JIT Code) Unity.Entities.Editor.HierarchyEntityChangeTracker:.ctor (Unity.Entities.World,Unity.Collections.Allocator) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/Model/ChangeTracking/HierarchyEntityChangeTracker.cs:212)
0x000001e53f105a33 (Mono JIT Code) Unity.Entities.Editor.HierarchyUpdater:SetWorld (Unity.Entities.World) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/Model/HierarchyUpdater.cs:190)
0x000001e5145bb9e3 (Mono JIT Code) Unity.Entities.Editor.Hierarchy:SetWorld (Unity.Entities.World) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/Model/Hierarchy.cs:436)
0x000001e53f104fcb (Mono JIT Code) Unity.Entities.Editor.HierarchyWindow:OnWorldSelected (Unity.Entities.World) (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Hierarchy/HierarchyWindow.cs:301)
0x000001e53f10494a (Mono JIT Code) Unity.Entities.Editor.DOTSEditorWindow:Update () (at ./Packages/com.unity.entities@1.0.0-pre.44/Unity.Entities.Editor/Common/DOTSEditorWindow.cs:193)```
constant crash from hierarchy window on loading unity 😦 can't even get into app
this seems related to ^
removing the check has let me into unity
this didn't work btw
EntityQueryDescValidationException: EntityQuery contains a filter with duplicate component type name Cluster. Queries can only contain a single component of a given type in a filter.
private partial struct ClusterInitializeJob : IJobEntity, IJobEntityChunkBeginEnd
{
private void Execute(Entity entity, [WithChangeFilter] ref Cluster cluster, in TransformAspect transform)```
still throws
What. I'm just learning this now.
Also RIP workaround.
then again this is why we shouldn't have internal access - this is not safe 😅 - if someone did need something the safe version will be in my library soon
Bummer, had high hopes there 🥲 guess you have to wait
6. InvalidOperationException: The Unity.Entities.DynamicComponentTypeHandle DidChangeJob.JobData.TypeHandle can not be accessed. Nested native containers are illegal in jobs.
private struct DidChangeJob : IJobChunk
{
[ReadOnly]
public DynamicComponentTypeHandle TypeHandle;```
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var currentFrameIndex = this.frameIndex;
var debug = SystemAPI.GetSingleton<BLDebug>();
for (var index = 0; index < this.typeTracks.Length; index++)
{
var track = this.typeTracks[index];
track.TypeHandle.Update(ref state);
this.jobHandles[index] = new DidChangeJob
{
TypeHandle = track.TypeHandle,
Changed = track.Changed,
Chunks = track.Chunks,
Index = currentFrameIndex,
LastSystemVersion = state.LastSystemVersion,
}
.Schedule(track.Query, state.Dependency);
}
state.Dependency = JobHandle.CombineDependencies(this.jobHandles);
}```
Yes I have a NativeArray of DynamicComponentTypeHandles but they only exist within the system, not on a component or anything and never passed into a job as a anything but the pure handle
I don't see why / how this is a failure
If I only have an array of length 1 it also doesn't error/care
only when I have a second
chaining dependencies instead of scheduling in parallel doesn't help
Unity.Entities.Editor.HierarchyNodeStore.SetParent (Unity.Entities.Editor.HierarchyNodeHandle handle, Unity.Entities.Editor.HierarchyNodeHandle parent) (at ./Library/PackageCache/com.unity.entities@85b209eab7/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore.cs:405)
Unity.Entities.Editor.HierarchyNodeStore+IntegrateGameObjectChangesEnumerator.IntegrateChanges () (at ./Library/PackageCache/com.unity.entities@85b209eab7/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+GameObjectChanges.cs:259)
Unity.Entities.Editor.HierarchyNodeStore+IntegrateGameObjectChangesEnumerator.MoveNext () (at ./Library/PackageCache/com.unity.entities@85b209eab7/Unity.Entities.Editor/Hierarchy/Model/HierarchyNodeStore+GameObjectChanges.cs:108)```
Most of these seemed fixed but this one still happens, not really sure how I triggered it was just in game. Doesn't seem to break anything though.
Pretty sure it's cinemachine though.
Entities Hierarchy bug I guess 🤔