Start a new topic

Android + PhoneGap + Wikitude - Backbutton after onPause

Android + PhoneGap + Wikitude - Backbutton after onPause

Hello everyone, I'm using Wikitude SDK as PhoneGap plugin as described here:

I'm able to create my own PhoneGap application an then load Wikitude as following:


var pg = WikitudePlugin;



// To be able to respond on events inside the ARchitect World, we set a onURLInvoke

// callback


pg.onWikitudeOK = app.actions.AR.onWikitudeOK;

pg.onWikitudeError = app.actions.AR.onWikitudeError;

pg.onARchitectWorldFailedLaunchingCallback = app.actions.AR.onARchitectWorldFailedLaunchingCallback;

pg.onARchitectWorldLaunchedCallback = app.actions.AR.onARchitectWorldLaunchedCallback;


Everything goes fine until I click on one of mine drawables, for example to open the system browser.

In this case, Wikitude goes into onPause state and the onWikitudeOK callback says: "onPause: architectView is present". So, when i press the hardware back button on my Android, and correctly see the small wikitude logo  on the bottom of the screen (I'm using trial SDK at the moment), but the screen is completely black and LogCat says:


04-11 15:20:08.860: E/dalvikvm(11227): JNI ERROR (app bug): attempt to use stale local reference 0x1

04-11 15:20:08.865: E/dalvikvm(11227): VM aborting

04-11 15:20:08.865: A/libc(11227): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)


After a couple of seconds, my app crashes.

Can anyone help me? Thanks.



Hi Mattia,

Back-button needs some special handing in phoneGap to ensure ARchitectView gets informed about lifecycle properly.
Please have a look at the provided Sample to recheck your back-button implementation.

Kind regards,

Hi Andreas, thanks for your reply.

I've followed the github examples and found where the problem is. My implementation of backbutton was already ok but I've discovered that filesystem operations during image recognition (ARView active) make the app crash.

In my app, i used to clean a cache folder where my phonegap application stores some files. During phonegap "Resume" event, I open this folder to remove every file it contains and Wikitude SDK seem to get really upset. I've tried to delay this operation (with setTimeout), but since the operation start (for example after 5 seconds), the ARView hangs, and then the app crashes.

OK, so you somehow solved the issue right?

Please avoid in general to execute heavy tasks while Wikitude Cam is pausing or resuming.
Would be better to clean-up when e.g. returning from cam to your phonegap screen.


Yes, thanks, I think I'll fix it somehow.

However, if this is (or will be) a known problem, It would be great if you place a tip in your phonegap's plugin setup page, a sort of "best practice" to advise developers to avoid to use filesystem until Wikitude has been paused/stopped/whatevered.

Therefore, I think that implementing of backbutton event must be delegated to a custom phonegap callback, because in my case, when my app resume, event tough Wikitude ARView become again visible and active, Phonegap is handling the operations instead of Wikitude ARView: in this case, pressing the backbutton, won't keep me back to phonegap screen but exit application. I'll investigate and debug more for this problem.

Thank you so much Andreas.
Login or Signup to post a comment