Start a new topic

Memory Leak/Crash on iOS

Memory Leak/Crash on iOS

1 person has this problem


Hi everybody. Has anyone had any luck with this bug fix Andreas posted? I'm afraid to say we haven't. I downloaded the plugin, replaced the files, put our licence and the app worked exactly the same as before, that is it still crashes. It crashes in just the same way as before. if the target augments one image it crashes after 16 times. If there are two it crashes after eight if it augments a video it crashes much earlier. As Andreas said in the post that it was a problem with the video drawables I even removed all the video drawables. The app is creating none but the result is the same even if there's only image drawables. Well unforunately this is our feedback up to now, we're waiting to hear from you guys, regards:

 

Axel

Hi I'm having the same problem. Only that it takes about 8 times of entering and exiting field of vision for the app to crash

Hi i installed yesterday the cordova plugin, not always, sometimes, and the memory increase in iphone each second (CPU 97% and memory 0 - 60%), during this my iphone 6 is disabled and when the memory reach at more than 60-70%  the app crash, my code:

 

  var World = {

    tracker: null,

    btn_scan: document.getElementById('scanButtonWrapper'),

    errorMessage: document.getElementById('errorMessage'),

 

    init: function initFn () {

      this.createTracker()

      //  this.createOverlays();

    },

 

    /*

      First an AR.CloudTracker needs to be created in order to start the recognition engine.

      It is initialized with your cloud identification token and the id of one of your target collections.

      Optional parameters are passed as object in the last argument. In this case callback functions for the onLoaded and onError triggers are set.

      Once the tracker is fully loaded the function worldLoaded() is called, should there be an error initializing the CloudTracker the

      function trackerError() is called instead.

    */

    createTracker: function createTrackerFn () {

      World.tracker = new window.AR.CloudTracker('xxxxxxx', 'xxxxxx', {

        onLoaded: function () {},

        onError: function (errorMessageTxt) {

          window.alert(errorMessageTxt)

        }

      })

    },

 

    /*

      The onRecognition callback function defines two parameters. The first parameter is a boolean value which indicates if the server was able

      to detect the target, it's value will be 0 or 1 depending on the outcome. The second parameter a JSON Object will contain metadata about

      the recognized target, if no target was recognized the JSON object will be empty.

    */

    onRecognition: function onRecognitionFn (recognized, response) {

      World.btn_scan.className = ''

      if (recognized) {

        console.log(recognized)

        console.log(response)

        console.log(response.metadata)

        window.AR.context.destroyAll()

        document.location = 'architectsdk://getData=' + JSON.stringify(response.metadata)

      } else {

        /*

          Image recognition failed. An error message will be displayed to the user.

        */

        World.errorMessage.className = ''

        //  window.alert('error code:')

      }

    },

 

    onRecognitionError: function onRecognitionError (errorCode, errorMessageTxt) {

      World.btn_scan.className = ''

      World.errorMessage.className = ''

    },

 

    /*

      In this function the recognition will be started, it is triggered by the onClick event of the scanButton.

    */

    scan: function scanFn () {

      /*

        The tracker recognize function is passed two callback functions. The first callback function will be called by the server after each

        recognition cycle. The second callback defines an on error callback function. It will be called if there is something wrong in

        your cloud archive.

      */

      World.btn_scan.className = 'clicked'

      World.errorMessage.className = 'hidden'

      World.tracker.recognize(this.onRecognition, this.onRecognitionError)

    },

 

    close: function closeFn () {

      window.AR.context.destroyAll()

      document.location = 'architectsdk://closeAR=true'

    }

  }

 

  World.init()

 

and when the another webview (ionic project) is enter i do:

 

$rootScope.wikitudePlugin.close(), so i close wikitude....

 

Thanks for all

 

 

 

 

 

Hi Axel,
Can you send us a demo project with which we can reproduce the issue? I would really like to have a closer look at this.

Best regards

Andreas

The latest phonegap plugin did not fix it for us either.

We only use the CloudTracker class without any drawables, pure the recognition of a target as test.
This crashes after ±8x in iOs and a bit longer for Android.

Our workaround was making use of AR.context.destroyAll() after each scan.
This works but you will need to recreate the tracker again and no augmentation being defined.

After AR.context.destroyAll() is being called the method cloudTracker.isLoaded() will never get set to true

 

World.cloudTracker = new AR.CloudTracker("__your_authentication_token__", "__target_collection_id__", {
onLoaded: World.trackerLoaded,
onError: World.trackerError
});

trackerLoaded: function trackerLoadedFn() {
console.log(World.cloudTracker.isLoaded());//always false after AR.context.destroyAll()
}



if using World.cloudTracker.destroy(); this crashes the app immediately.

So our AR is only working the first time and won't work after destroyall.
I can send you a sample project but this is really easy to reproduce.


Best regards,

Sang.

Hi daichi,
We released a new verison of our SDK including all extensions just a few days ago. The Titanium version now contains all fixes mentioned earlier in this thread plus additional ones that we made specific for the release.

If you continue to encounter the issue you mentioned, can you please send us a Titanium demo project with which we can reproduce the issue? THX!

Best regards,

Andreas

Hi Axel,
What's the implementation of your enter/exitFOV trigger?

Best regards

Andreas

Hi, sure, you can clone the gitub repo at 

 

https://github.com/axelweisz/support.git

 

It augments some images of our own but you can test it using two of the images of your sample apps, the oune eith the guy with the surfboard and the other of the racer guy that augments an helmet 

 

regards:

 

Axel

Hi there, I'm pasting it down here but let me do some explaining first for the code is a little complex because it gets data from Firebase service. The code is part of an app that we developed based on wikitude's multiple targets example and works fine (until the 8th or 14th augmentation, depending how many objects it creates at any given OEFV). The complete code can be clone at https://github.com/axelweisz/seeBeyondDemo. To illustrate further the memory problem, we noticed that if we leave the AR screen (that is go back to the home page) the objects do void from memory and the count until the (unforunately inevitable) crash of the app starts over. Well there goes the code:

 

var World = {

loaded: false,

init: function initFn() {

this.createOverlays();

},

createOverlays: function createOverlaysFn() {

//create firebase object

var fb = new Firebase("https://testejsontr.firebaseio.com");

var db = fb.on("value", function(snapshot){

var db = snapshot.val(); //get the whole database

var baseUrl = db.baseUrl;

var tgtColl = db.targetCollection; //get the target collection

//creates the tracker

var tracker = new AR.ClientTracker(baseUrl+tgtColl, {

onLoaded: function worldLoadedFn() {

var e = document.getElementById('loadingMessage');

e.parentElement.removeChild(e);

$("#scanBar").show();

}

});

//create arrays for targets, augmentations and augmentations options

var tgtsArray = db.targets;

var augmentsObjs = db.augments;

var optionsObjs = db.augmentOpts;

//create the arrays that will store the objects (trackable2Dobjects, drawables and camDrawables) 

World.overlaysImg = ;

World.trackablesImg = ;

World.emptyCamArrayImg = ;

/*** MAIN LOOP ***/

//creates a trackable for each target in the target collection (tgtsArray)

for(var i = 0; i < tgtsArray.length; i++){

//create the trackables

World.trackablesImg = new AR.Trackable2DObject(tracker, tgtsArray.name, {

drawables: {

cam: World.emptyCamArrayImg //start the camDrawables with an empty array

},

onEnterFieldOfVision: (function (ii) {

return function(e) {

$("#scanBar").hide();

//loop to try do clean the memory from the objects before creating the augmentations

for(var k = 0; k < World.emptyCamArrayImg.length; k++){

this.drawables.removeCamDrawable(k);

World.emptyCamArrayImg = null;

World.overlaysImg.destroy();

World.overlaysImg = null;

}

var tgtAugmentsArray = tgtsArray.augments;//get the augmentations for each target

for(var j = 0; j < tgtAugmentsArray.length; j++){

var aumentation = augmentsObjs;

var options = optionsObjs;

var file = baseUrl+aumentation.filePath; 

var type = aumentation;

//creating the drawable according to the type of aumentation (image, video, etc)

if(type=="img"){

var imgRes = new AR.ImageResource(file);

World.overlaysImg = new AR.ImageDrawable(imgRes, options.scale, {

offsetX: options.offsetX,

offsetY: options.offsetY,

zOrder: options.zOrder

}

);

this.drawables.addCamDrawable(World.overlaysImg);//add the drawable to camDrawable

} else if(type == "btn"){

var imgRes = new AR.ImageResource(file);

World.overlaysImg = new AR.ImageDrawable(imgRes, options.scale, {

offsetX: options.offsetX,

offsetY: options.offsetY,

zOrder: options.zOrder,

onClick : function() {

AR.context.openInBrowser(options.link, true);

}

 

}

);

this.drawables.addCamDrawable(World.overlaysImg);//add the drawable to camDrawable

}else if (type == "video"){

World.overlaysImg = new AR.VideoDrawable(file, options.scale, {

offsetX: options.offsetX,

offsetY: options.offsetY,

zOrder: options.zOrder, 

isTransparent: options.isTransparent

 

})

this.drawables.addCamDrawable(World.overlaysImg);//add the drawable to camDrawable

World.overlaysImg.play();

}

}

};

})(i),

onExitFieldOfVision: (function (ii) {

return function(e) {

//trying to delete the objects and free the memory also here

var thisTrckbl = this;

var tgtAugmentsArray = tgtsArray.augments;

for(var j = 0; j < tgtAugmentsArray.length; j++){

thisTrckbl.drawables.removeCamDrawable(j);

World.emptyCamArrayImg = null;

World.overlaysImg.destroy();

World.overlaysImg = null;

}

//counting scans

fb.child("scans/"+tgtsArray.name+"/totalScans").transaction(function(currentValue){

return (currentValue||0) + 1

}, 

function(err, committed, ss) {

if( err ) {

  console.log("erro: " + err);

} else if( committed ) {

          console.log("novo valor: " + ss.val()); 

       }

}

);

fb.child("scans/"+tgtsArray.name + "/scanTimes").push({

scan: Firebase.ServerValue.TIMESTAMP

});

$("#scanBar").show();

};

 

 

})(i)

});

}

});

},

 

worldLoaded: function worldLoadedFn() {

var e = document.getElementById('loadingMessage');

e.parentElement.removeChild(e);

}

};

 

World.init();

I've been playing with Wikitude via the Phonegap/Cordova plugin for a couple of weeks now and have been extremely impressed overall.

While testing my app, I noticed that if I launch and exit my AR World enough times my application would eventually crash.  I then tried the same experiment with your sample Cordova app and experienced the same thing.  After repeatedly entering and exiting one of the AR worlds on the menu (I don't believe the actual world matters but I was using 7.1 - Simple Video), the application would eventually crash.  Shortly before the app crashes, I the lldb console starts indicating a memory warning each time we enter the view and when it does crash, the lldb console indicates "Process xxx exited with status = 0 (0x00000000) Terminated due to Memory Error.  It takes around 20-25 visits to the AR world to cause the problem but it can be reproduced consistently.

Note that this is only happening on iOS.  Android does not seem to have the same issue.

I'm running on iOS 8.3, and using Cordova 4.3.0.

As I'm pretty much following the same patterns as the sample app for launching and closing my AR world and both applications exhibit the exact same behavior, I'm assuming that the issue resides with the native plugin implementation or the Wikitude SDK itself.  If I'm mistaken, please let me know how the source code for the sample app can be modified to correct this issue and, if not, I'm hoping you can provide an ETA for a fix.

Thanks in advance.

Hi Axel,
thx for sharing the snippet. I read it and now have some follow up questions:

Are you sure that all drawables (VideoDrawable & ImageResources/ImageDrawables) are .destroyed() before you recreate them in your vision trigger?

Can you send us the crash report? I would be interested if it is a crash because of a null ptr. or memory preasure.

Best regards

Andreas

 

I have almost the same problem with Titnaium plugin.

Deleted AR.VideoDrawable doesn't release memory and cause memory reak warning.

Do you have a plan to release new Titanium version or some pre-release version?

I bought licence both iPhone/Android already.

I really appreciate if you give me some information.

 

 

 

Hi Jake,
I will try to reproduce your problem and get back to you with more details.

Thx for reporting your finding.

Best regards

Andreas

For what it's worth, I never managed to resolve the issue I raised at the beginning of this thread (which appears to be the same as Axel's).  It would be extremely useful if you could provide a version of the demo app that did not exhibit the same crash problem (I tried extensively to get to one, BTW).  We could then use the techniques in that example to design and fix our own apps.

we are having the same issues. When I keep scanning I get memory warnings and then a crash of the app. Attached a log of messages I get from my iphone 4s

 
Login or Signup to post a comment