Search Issue Tracker

Won't Fix

Votes

0

Found in [Package]

2.6.0-exp.2 - Collections

Issue ID

ECSB-1668

Regression

No

UnsafeBitArray.Find() method returns the wrong index and goes beyond the given scope to find the index

Package: Unity Native Collections

-

How to reproduce:
1. Open the “BitsTest.zip“ project
2. Open the “SampleScene“
3. Enter Play Mode
4. Observe the Console

Expected result: “Assertion failed” error is not thrown
Actual result: “Assertion failed” error is thrown

Reproducible in: 1.1.0, 2.6.0-exp.2 (2022.3.62f1, 6000.0.48f1, 6000.1.2f1, 6000.2.0a10)

Reproduced on: Windows 11 Pro (24H2)
Not reproduced on: No other environment tested

  1. Resolution Note:

    This is actually not a bug. When searching, algorithm prefers finding 0 bits fast, not optimal set of bits. Because user is creating 100 bits array, find has extra storage to give fastest results. Search will narrow down to smaller gaps which are more expensive to search for once there are no 0-bits in faster to find range.

    For example if you limit search to first 16 bits, instead full range of bit array, you would get desired results:

    Instead:
    Debug.Assert(bits.Find(0, 5) == 4); // checks 5 bits starting from index 0 - should return 4, and therefore not fail the assertion

    Try:
    Debug.Assert(bits.Find(0, 16, 5) == 4); // checks 5 bits starting from index 0 - should return 4, and therefore not fail the assertion

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.