Elementa icon indicating copy to clipboard operation
Elementa copied to clipboard

Fix SiblingConstraint Crash: Add Size check before getting child

Open MrFast-js opened this issue 1 year ago • 2 comments

The new code checks if index - 1 is possible for the children array, and if its not return the value without it, this is better than before because before if the children's size changes quickly, in my case for a search bar only showing certain results, and sometimes it would crash, this fixes that crash.

MrFast-js avatar Feb 01 '24 03:02 MrFast-js

If I'm understanding correctly, this is for cases where component.parent.children.indexOf(component) is -1, but this being true seems like it would only occur when something "illegal" is being done (like operations from another thread). Can you provide a minimal example that reproduces this, if it is really a bug that should be fixed in Elementa?

DJtheRedstoner avatar Feb 01 '24 04:02 DJtheRedstoner

yes @DJtheRedstoner, I have run into this crash when quickly hiding and unhiding elements, in this example its when I press the features "options" button (the gear) that can be found on lines #649-661, I can't force it to happen, and seemed to happen almost randomly when clicking on the gear, sometimes it would crash other times it would be fine, but the times it did crash it always pointed to that file having a input of -1 and it checking children[-2] thus crashing with array out of bounds .

MrFast-js avatar Feb 02 '24 00:02 MrFast-js