#[Bug] EnabledRefRW set always changes m_PtrChunkDisabledCount even if values match

1 messages · Page 1 of 1 (latest)

azure aurora
#

-edit- simplier repo and actual problem with code below
Error (full stack below)

Assertion failure. Values are not equal.
Expected: 2 == 1```

Repo
```cs
        [Test]
        public void BrokenTest()
        {
            var entity = this.Manager.CreateEntity(typeof(Active), typeof(ActivePrevious));
            this.Manager.SetComponentEnabled<Active>(entity, false);
            this.Manager.SetComponentEnabled<ActivePrevious>(entity, false);

            var system = this.World.CreateSystem<TestSystem>();
            system.Update(this.WorldUnmanaged);
        }

        public partial struct TestSystem : ISystem
        {
            /// <inheritdoc />
            [BurstCompile]
            public void OnUpdate(ref SystemState state)
            {
                new SetPreviousJob().ScheduleParallel();
            }

            [BurstCompile]
            [WithChangeFilter(typeof(Active))]
            [WithOptions(EntityQueryOptions.IgnoreComponentEnabledState)]
            private partial struct SetPreviousJob : IJobEntity
            {
                private void Execute(EnabledRefRW<ActivePrevious> previous, EnabledRefRO<Active> active)
                {
                    previous.ValueRW = active.ValueRO;
                }
            }
        }

        public struct Active : IComponentData, IEnableableComponent
        {
        }

        public struct ActivePrevious : IComponentData, IEnableableComponent
        {
        }```
#

actually repo is much simplier than that

#
            [BurstCompile]
            [WithOptions(EntityQueryOptions.IgnoreComponentEnabledState)]
            private partial struct SetPreviousJob : IJobEntity
            {
                private void Execute(EnabledRefRW<ActivePrevious> previous)
                {
                    previous.ValueRW = false;
                }
            }```
#
        public unsafe bool ValueRW
        {
            get => m_Ptr.GetBit();
            set
            {
                m_Ptr.SetBit(value);
                Interlocked.Add(ref UnsafeUtility.AsRef<int>(m_PtrChunkDisabledCount), value ? -1 : 1);
            }
        }```
m_PtrChunkDisabledCount is always added/subtracted regardless if the value is different
#

[Bug] EnabledRefRW set always changes m_PtrChunkDisabledCount even if values match

zenith gyro
#

EnabledMask is also affected by this bug.

west jolt
#

on it, thank you!