botoman Posted November 30, 2018 Share Posted November 30, 2018 Hello, We're experimenting some issues with Safari Mobile on iOS (iPhone X, iOS 12.1). Connecting the iPhone to Mac OS and using the Web Inspector, we see these errors (screenshot in attachment). It seems that the canvas memory is leaking and, as result of that, the engine is unable to create new objects. Is there anybody that can shed some light on this? Thanks, Alessio Quote Link to comment Share on other sites More sharing options...
enpu Posted November 30, 2018 Share Posted November 30, 2018 Can you show your code where you are using tint? Quote Link to comment Share on other sites More sharing options...
botoman Posted November 30, 2018 Author Share Posted November 30, 2018 Hi @enpu, Thank you for your quick answer. We've digged up into the problem and we're working to provide you a simplified version of the code, as soon as possibile Alessio Quote Link to comment Share on other sites More sharing options...
botoman Posted November 30, 2018 Author Share Posted November 30, 2018 Hi @enpu This is the first snippet that is creating the problem: game.module( 'game.main' ) .body(function() { game.addAsset('sprite.png'); game.createScene('Main', { init: function() { this.sprite = new game.TilingSprite('sprite.png', game.width, game.height); this.sprite.addTo(this.stage); this.sprite2 = new game.Sprite('sprite.png'); this.sprite2.anchorCenter(); this.sprite2.x = game.width/2 this.sprite2.y = game.height/2 this.sprite2.addTo(this.stage); }, update: function() { this.sprite.tilePosition.x -= 300 * game.delta; this.sprite.tilePosition.y -= 100 * game.delta; }, keydown: function(key) { if (key === 'SPACE') { game.system.setScene("Main"); } } }); }); As you can see, with the space key you navigate from one scene to the next (in this simple example is the same) As you can see from the following screenshots, the canvas of the tilingSprite is not removed and is leaking memory Instead the removal of the normal sprite is dealt properly. We will follow with another example of a leaking canvas in the following hours. Quote Link to comment Share on other sites More sharing options...
botoman Posted November 30, 2018 Author Share Posted November 30, 2018 Here you can also find the sprite we used to reprocude this basic sample. Quote Link to comment Share on other sites More sharing options...
botoman Posted November 30, 2018 Author Share Posted November 30, 2018 Hi @enpu Here's the second example that leak canvas memory: game.module( 'game.main' ) .body(function() { game.addAsset('minecraft.fnt'); game.createScene('Main', { init: function() { var text=Math.random()*1000; text=~~(text) var etext = new game.Text(text); etext.addTo(this.stage) etext.cache = true; etext._cachedSprite.tint = "#668899"; etext._cachedSprite.tintAlpha = 1; }, update: function() { }, keydown: function(key) { if (key === 'SPACE') { game.system.setScene("Main"); } } }); }); As you can see, the canvas related to the cached text remains in memory even after the scene is different. Down here there is the file minecraft_0.png which is transparent. minecraft.fnt Quote Link to comment Share on other sites More sharing options...
enpu Posted November 30, 2018 Share Posted November 30, 2018 First of all, thanks for the examples. Really appreciate it! TilingSprite cache gets cleared every time you set new scene. Are you sure that the "Canvas" page in developer tools actually shows everything that is currently loaded in memory? I had a little play with it and could not get anything removed from it, even though i manually deleted stuff. Do you have any example where something disappears from the Canvas debugging tab (after it appears), without reloading the whole page? Quote Link to comment Share on other sites More sharing options...
tricksty77 Posted November 30, 2018 Share Posted November 30, 2018 Hi, Enpu, I am also working on that project, Yes we are positive that canvas memory is being used up as at some point we recive a memory error and the creation of another 2d canvas fail. Is possible to have a way to configure a variable to disable the clearTilingSpriteCache on scene change? At least in the first example we would not create the same canvas again and again (and the behavior is like the normal sprite object which canvas is not recreated) Thanks Quote Link to comment Share on other sites More sharing options...
enpu Posted November 30, 2018 Share Posted November 30, 2018 I'm still trying to figure out what the actual issue is. That's why i was wondering if looking at the Canvas tab in developer tools is really the correct way, because i was unable to get anything removed from that. Creating canvas again and again should not be issue, if the previous one gets removed from memory (as it should). Quote Link to comment Share on other sites More sharing options...
enpu Posted November 30, 2018 Share Posted November 30, 2018 Ok i can now reproduce the issue, there is definitely something wrong with TilingSprite. Will try to fix it asap! Quote Link to comment Share on other sites More sharing options...
enpu Posted November 30, 2018 Share Posted November 30, 2018 This should be now fixed. Please update to latest dev version 2.10.1 and try again. Thanks for finding this pretty serious issue! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.