Crash only in IOs

Hi everyone, in this momment I’m working in a project with cocos creator v1.9.1 but I have a problem with IOs, when I try load a scene the game crash and only show a message “the page was reloaded because a problem occurred several times”

10%20AM

I have an Ipad Air model MD785E/A with IOs version 12.0.1 and I try to run the game in safari. This is a code fragment, when is trying to load the next scene:

var callback = function ()
{
cc.director.preloadScene(“LevelGame”, function () {
waitingLoadScene = true;
console.log("The scene is load ");
cc.director.loadScene(‘LevelGame’); //change scene
cc.sys.garbageCollect();
this.node.getComponent(“PlaySound”).MakeSound(0);
},);
}
this.scheduleOnce(callback, 3);

Finally when I debug on my Mac the safari’s Ipad it’s close when the page crash and show the message.

PD: I have the same safari’s version in the Mac and in the Ipad.
PD2: That error show only in IOs device.

Thanks

mmm I did some test for the game, and I think the problem is the device’s memory, because in diferents parts i have more than 1 GB in using. If you look the pictures the “problem” are the “layers”, I don’t understand that so much, but if someone can help me i will be so happy and grateful.

you can use cc.loader.release to release some unused resources,and check the option “auto release” of your scene.
image

Hi @Big_Bear thanks for the advice, but I already use in this moment, I have two scenes and I’m using in both of them…

1 2

finally I used cc.loader.releaseAll() and the numbers down and I can run the game (thaaaaaanks!!), but the game runs so slow…

Any other advice?

Don’t use cc.loader.releasAll().
loadScene is asynchronous,if you release some resources of the old scene,it will be cause crash.
And cc.loader.releaseAll() will release all dynamic loaded resources,but some resources is loaded for next scene.it is also a problem.

I provide a thought for you.
Your can use cc.director.getScene().dependAssets before the callback of loadscene to get all depend resources of old scene,and release them on load scene finished.

Like:

var oldAsset = cc.director.getScene().dependAssets;
cc.director.loadScene('newscene',null,function(){
      cc.loader.release(oldAsset);
})

To attention,this solution is used for the situation that we don’t have any shared resources between the old and next.

If you have some shared assets, your can compare the depend assets between the old and next.get the shared and release

Like:

        var oldAsset = cc.director.getScene().dependAssets;
        cc.director.loadScene('newscene',null,function(){
            var newAsset = cc.director.getScene().dependAssets;
            var notsharedAsset = ......//to do: get no shared assets
            cc.loader.release(notsharedAsset);
        });

Reference:Prevent auto releasing for some specifed assets

Well… I tried to release only no-assets shared but, that doesn’t enough I don’t know what I can do… my problem are the “layers” in web inspector on IOs, and I don’t know what is that?? (the layers).
@Big_Bear thanks for everything!!

Ok my friends … I can do it !!! Thanks, @Big_Bear, your advice helped me a lot. If someone is interested, I should have done many things.

  • I need to create an intermediate scene between my main scenes.
  • In that scene I use “cc.loader.getDependsRecursively”, “cc.sys.garbageCollect ();” and “cc.loader.release (noSharedAsset);” Thist with the advice of @ Big_Bear.
  • I also need to delete a lot of coconuts, “cc.renderer”, “cc.rendererCanvas” and “cc.rendererWebGL”.
  • I used “Auto Release Assets” in all the scenes.
  • I didn’t use the “Auto Atlas”

Poasdata: I sacrificed the load time for memory space.

Happy in offering helps :+1::+1::+1:

1 Like