Missing textures crash the renderer
Closed this issue · 6 comments
Encountered in the 1.0.2 (and earlier) versions of OMORI, as discussed on the Steam bug reports page.
It seems to use a different fork of pixi-tilemap, judging by the slightly different variable names, so it has to be verified if this issue is present in this version.
In the implementation of renderCanvasCore in RectTileLayer.ts there is no check to see if a texture is defined or not, thus leading to crashes with Uncaught TypeError: Cannot read property 'baseTexture' of undefined.
if it does not.
My proposed fix is modifying the if condition to be textureIndex >= 0 && this.textures[textureIndex] !== undefined
, so that undefined textures are skipped, but I'm not sure whether that is computationally efficient.
Instead of crashing, a more useful behaviour would be logging the error for the developer to see.
textureIndex >=0 && this,textures[textureIndex]
should be fine. drawImage
costs much more than those ifs.
Care to make a PR?
Is there a standard for error logging in this project, or should I just leave it ignored?
No standards, just leave it ignored for now.
textures
were supposed to have nulls or undefineds for rpgmaker mv, and i remember that Omori uses it, right?
Good!
Those checks exists in webgl: https://github.com/pixijs/pixi-tilemap/blob/master/src/TileRenderer.ts#L52
and missing in canvas2d, so you can make PR for it if you want, it doesnt need console message