From 8b0224e7b4b35f7f72319785c5e497b8f67f49f1 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 12 Nov 2015 13:39:42 +0000 Subject: [PATCH 1/3] TilemapParser accidentally redeclared `i` when parsing the ImageCollections which would cause an infinite loop (thanks DanHett) --- README.md | 1 + src/tilemap/TilemapParser.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4d631f447..60677b491 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser ### Bug Fixes * Buttons (or any Sprites) that don't have a texture, but have children, would incorrectly render the children under WebGL due to the baseTexture.skipRender property (thanks @puzzud #2141) +* TilemapParser accidentally redeclared `i` when parsing the ImageCollections which would cause an infinite loop (thanks DanHett) ### Pixi Updates diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index 98b53c11d..b47b947ff 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -446,10 +446,10 @@ Phaser.TilemapParser = { { var newCollection = new Phaser.ImageCollection(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing, set.properties); - for (var i in set.tiles) + for (var ti in set.tiles) { - var image = set.tiles[i].image; - var gid = set.firstgid + parseInt(i, 10); + var image = set.tiles[ti].image; + var gid = set.firstgid + parseInt(ti, 10); newCollection.addImage(gid, image); } From 3d1306d4400c16945bb584a5bf4fcdac4660141a Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 17 Nov 2015 14:07:48 +0000 Subject: [PATCH 2/3] jsdoc fix. --- src/tilemap/TilemapParser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index b47b947ff..b583621b1 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -78,6 +78,7 @@ Phaser.TilemapParser = { * Parses a CSV file into valid map data. * * @method Phaser.TilemapParser.parseCSV + * @param {string} key - The name you want to give the map data. * @param {string} data - The CSV file data. * @param {number} [tileWidth=32] - The pixel width of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. * @param {number} [tileHeight=32] - The pixel height of a single map tile. If using CSV data you must specify this. Not required if using Tiled map data. From 609b38c6e1455a83a63add6134ee87a17635b46f Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 17 Nov 2015 14:07:56 +0000 Subject: [PATCH 3/3] BitmapData.update causes a snowballing memory leak under WebGL due to a Context.getImageData call. BitmapData.clear used to call update automatically but no longer does. This resolves the issue of the Debug class causing excessive memory build-up in Chrome. Firefox and IE were unaffected (thanks @kingjerod #2208) --- README.md | 1 + src/gameobjects/BitmapData.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60677b491..8deb30352 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser * Buttons (or any Sprites) that don't have a texture, but have children, would incorrectly render the children under WebGL due to the baseTexture.skipRender property (thanks @puzzud #2141) * TilemapParser accidentally redeclared `i` when parsing the ImageCollections which would cause an infinite loop (thanks DanHett) +* BitmapData.update causes a snowballing memory leak under WebGL due to a Context.getImageData call. BitmapData.clear used to call update automatically but no longer does. This resolves the issue of the Debug class causing excessive memory build-up in Chrome. Firefox and IE were unaffected (thanks @kingjerod #2208) ### Pixi Updates diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index c357d9f11..d2c497b33 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -441,6 +441,9 @@ Phaser.BitmapData.prototype = { * You can optionally define the area to clear. * If the arguments are left empty it will clear the entire canvas. * + * You may need to call BitmapData.update after this in order to clear out the pixel data, + * but Phaser will not do this automatically for you. + * * @method Phaser.BitmapData#clear * @param {number} [x=0] - The x coordinate of the top-left of the area to clear. * @param {number} [y=0] - The y coordinate of the top-left of the area to clear. @@ -457,8 +460,6 @@ Phaser.BitmapData.prototype = { this.context.clearRect(x, y, width, height); - this.update(); - this.dirty = true; return this; @@ -567,6 +568,8 @@ Phaser.BitmapData.prototype = { * It then re-builds the ArrayBuffer, the data Uint8ClampedArray reference and the pixels Int32Array. * If not given the dimensions defaults to the full size of the context. * + * Warning: This is a very expensive operation, so use it sparingly. + * * @method Phaser.BitmapData#update * @param {number} [x=0] - The x coordinate of the top-left of the image data area to grab from. * @param {number} [y=0] - The y coordinate of the top-left of the image data area to grab from.