Tree ids larger than 1048576 break the tracing view
Trees with an id larger than 1048576 (1024²) break the tracing view with a RangeError. A short investigation showed that the tree color texture for the shader is 1024² * 4 in size (because it saves RGBA) and tree ids are used as direct indices into the texture. This breaks for larger tree ids. I'm not sure whether there are other spots that break as well.
Trees with ids this large can be imported or (in theory) appear after creating that many trees in a tracing. When importing trees, their ids are usually relabeled to be much smaller, except in the case of a fresh tracing (as a performance optimization).
Full stack trace:
skeleton.js?63cc:591 Uncaught (in promise) RangeError: offset is out of bounds
at Float32Array.set (<anonymous>)
at Skeleton.updateTreeColor (skeleton.js:650)
at Skeleton.createTree (skeleton.js:468)
at Skeleton.reset (skeleton.js:130)
at eval (skeleton.js:84)
at Just.map (maybe.js:226)
at new Skeleton (skeleton.js:83)
at SceneController.createMeshes (scene_controller.js:350)
at SceneController.initialize (scene_controller.js:174)
at initializeSceneController (scene_controller.js:526)
If this is fixed, this check should be removed again.
two thoughts on this:
- an easy mitigation might be to simply hash large ids to a color (which cannot be modified by the user). it's not nice, but wouldn't crash if the rare case occurs.
- there might be overlap with #6030. having a dynamic lookup via hashing would solve this properly, I assume.