MSIE8 inserts empty nodes
IvanSanchez opened this issue · comments
I've found that, after adding enough data, MSIE8 creates nodes with infinite/-infinite coordinates (this will make the bush crash when more items are added, or when searching for an item).
The simplest reproducible case I could come up with is this:
var bush = rbush();
// Force the bush to split much earlier
bush._maxEntries = 2;
bush._minEntries = 1;
bush.insert( [-449,235,-329,277,] );
bush.insert( [-449,262,-425,286,] );
bush.insert( [-215,200,-49,242,] );
bush.insert( [-215,227,-191,251,] );
bush.insert( [222,98,298,140,] );
bush.insert( [222,125,246,149,] );
console.log(bush.data.children[1].bbox);
// On MSIE8: [Infinity, Infinity, -Infinity, -Infinity]
// Any other browser: [ -449, 200, -49, 286 ]
If _minEntries
and _maxEntries
are set to the default values of 4 and 9, the bug is reproducible after inserting about 30-40 items.
The bug is reproducible with MSIE8, or MSIE11 emulating MSIE8. I haven't tried polyfilling ecmascript5 functionality.
WAT!!! That's seriously WTF. No idea how that happens. Really curious to find the cause...
@IvanSanchez no JS error? (IE 8 does not have Array.prototype.indexOf for example.)
Doesn't look like there's any error thrown. Also, indexOf
is only used in the removal routine. Should be something on insert/split.
I found something off while tracing around here: https://github.com/mourner/rbush/blob/master/rbush.js#L317 , and then I found http://www.to-string.com/2012/05/29/fixing-splice-in-older-versions-of-internet-explorer-8-and-olders/
Also note that there is a ecmascript shim for Array.prototype.splice()
: https://github.com/es-shims/es5-shim/blob/master/es5-shim.js#L365
At this moment I'm partial to not "fixing" this and just making a note in the READMEs.