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
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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Prefabs with "Flags" enum properties result in "IndexOutOfRangeException" when trying to commit/revert
- The Camera first person mode in Cameras overlay is greyed out and not clickable when the Editor is restarted with the Game View focused
- Scene View doesn't select the Canvas when it's clicked with the View Tool
- Transform fields are impossible to edit when Inspector window is resized
- Actions in UI Builder Preview mode are not fully reset after exiting the Preview mode
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