Jump to content

Issue with mobile iOS


botoman
 Share

Recommended Posts

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

 

Screenshot.png

Link to comment
Share on other sites

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.

 

screen1.png

screen2.png

screen3.png

screen4.png

Link to comment
Share on other sites

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_0.png

minecraft.fnt

screen_B_1.png

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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