Jump to content

IndexSizeError in IE and Firefox when migrating from 2.6.2 to CE


Recommended Posts

We moved our game from Phaser 2.6.2 "Kore Springs" to 2.10.3 and encountered this error in Firefox and Internet Explorer:

IndexSizeError: Index or size is negative or greater than the allowed amount

The exception is trown from PIXI.Sprite.prototype._renderCanvas:

renderSession.context.drawImage(this.texture.baseTexture.source, cx, cy, cw, ch, dx, dy, cw / resolution, ch / resolution);

The arguments are:

cx : 803
cy : 899.37
cw : 168
ch : 0
dx : -0
dy : -0.6299999999999955
resolution : 1

Everything was fine in "Kore Springs" but we wanted to take advantage of all the fixes and updates on tilemaps in CE.

Link to comment
Share on other sites

I meant that if you floor the crop dimensions yourself, during updates, you may be able to avoid the error in during rendering. It doesn't really matter if you use Math.floor or the bitwise operation. You could do:

function update() {
  // ...
  obj.crop(/* ... */);

  var crop = object.texture.crop;
  // Avoid error in Sprite._renderCanvas:
  crop.width = Math.floor(crop.width);
  crop.height = Math.floor(crop.height);
  // ...

It expect it will work because Sprite._renderCanvas skips objects with crop dimensions of exactly 0. I haven't tested it though.

Probably we should add a fix in Phaser CE for this.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...