GetSingleton() failed: found no chunk that matches the provided filter.

Hello, I have a very straightforward system:

public partial struct MySystem : ISystem
{
    private EntityQuery _activePlayersQuery;

    public void OnCreate(ref SystemState state)
    {
        _activePlayersQuery = SystemAPI.QueryBuilder().WithAll<ActivePlayerTag, Transform>().Build();
        state.RequireForUpdate(_activePlayersQuery);
    }
   
    public void OnUpdate(ref SystemState state)
    {
        var activePlayerPosition = _activePlayersQuery.GetSingleton<Transform>().position;
        ...
    }
}

Where ActivePlayerTag is an empty IComponentData and Transform is the UnityEngine transform.
I’ve been reported a weird case in a build run where the GetSingleton() method generated this error:

Exception: InvalidOperationException: GetSingleton() failed: found no chunk that matches the provided filter.

Unity.Entities.EntityQueryImpl.GetSingletonChunk (Unity.Entities.TypeIndex typeIndex, System.Int32& outIndexInArchetype, Unity.Entities.Chunk*& outChunk) (at <00000000000000000000000000000000>:0)
Unity.Entities.EntityQueryManagedComponentExtensions.GetSingleton[T] (Unity.Entities.EntityQuery query) (at <00000000000000000000000000000000>:0)

Any Idea on what’s going on?

Did you manually add the transform via EntityManager.AddComponentObject?
Otherwise, you probably want to replace Transform with LocalTransform, since Transform is not an ECS-Component and you will usually not find it attached to any entity (Transform on GameObject will be baked to LocalTransform in resulting Entity).

Not sure why your system will even run though. If you just use “normal” baked entities, this query will not match anything. Since your query seems to contain something, maybe you can try ```
state.EntityManager.GetComponentObject(_activePlayersQuery.GetSingletonEntity())