Start a new topic

back button closes app after exiting AR

This is an issue that has been reported before: https://support.wikitude.com/support/discussions/topics/5000076660


This issue still repros for 5.x.


I've created a repo to repro it: https://github.com/panlina/wikitude.backbutton


Repro steps:

  1. click loadARchitectWorld to open AR
  2. press anywhere in the AR view
  3. press back button to close AR
  4. click 0.html to go to 0.html
  5. press back button

It is expected to go back to home page, but it actually closes the app.

Notice that step 2 is necessary to repro the issue.


Wikitude team, is there any fix for this issue? Or how can I workaround it?

Thanks.



Hi,


this issue is now fixed and will be included in the next release of the SDK.


Best Regards,

Alex

Got it, Daniel. Thank you for your following up!

Good morning Jack,



I can confirm this issue for the latest version of the plugin.


I created a ticket in our internal tracking system for it to be investigated. I cannot, however, give you any timeline on when exactly that investigation will actually happen. I'm afraid, it could be a while as this strikes me as a rather low priority issue which will be preceded by some more pressing matters.



- Daniel


Daniel,

I can confirm that this issue is fixed in 5.3.1. Thank you again. That's valuable to our app.

However I still see the issue I mentioned in my comment 2 floor down Eva's. There's no reaction to the press of back button right after exiting from AR. 1 more press is required to close the app. This is still causing navigation issues in our app.

Can you confirm this issue also?

Thanks.

Daniel,

It's really a good news to me if it's fixed in 5.3.1. I didn't try this version. I'll give it a try and get back to you.

Thanks for your work on this!

Hi Jack,



I extensively tested the project you provided and found the issue to be consistently reproducible up until version v5.3.0-3.3.1.


Past this version I tried versions v5.3.1-3.3.1, v6.0.0-3.4.0 and v6.1.0-3.4.2 (latest) and could not reproduce the issue anymore.


Since the newest version you mentioned in your postings is 5.3.0, I assume that you have not tried any of the versions I listed and the issue has actually been solved in v5.3.1-3.3.1.


My test device was a LG Nexus 5X running Android 7.1.2.



- Daniel


It repros again, for both versions. Can't get it working again.

Update..

Just now I tried reverting my changes in WikitudePlugin.java and build again, and found that the issue does not repro. I've tested repeatedly, and it just works fine every single time..

So..I'm confused. Does that mean it's kind of random?

I also found a typo in my change:

((CordovaWebView)rootView).getView().clearFocus(); //should be requestFocus

just as I posted above.

So seems that the good runs has nothing to do with my "fix".

Confused.

Comment my previous post: I also changed WikitudePlugin.js, commenting out back button callback:

WikitudePlugin.prototype.loadARchitectWorld = function(..) {
	..
	// We add an event listener on the resume and pause event of the application life-cycle
	document.addEventListener("resume", this.onResume, false);
	document.addEventListener("pause", this.onPause, false);
	//document.addEventListener("backbutton", this.onBackButton, false);
};


Oh, folks,

I managed to fix it by modifying WikitudePlugin.java. When AR view is removed, I let the WebView request focus. The back button works correctly now, for both scenarios I mentioned above.

private boolean removeArchitectView() {
	..
	this.architectView.setVisibility( View.GONE );
	((ViewManager)this.architectView.getParent()).removeView( this.architectView );
	//let WebView request focus
	WikitudePlugin.requestFocusInCordovaWebView(cordova.getActivity().getWindow().getDecorView().findViewById(android.R.id.content));
	this.architectView = null;
	..
}
where
private static void requestFocusInCordovaWebView(View rootView) {
	if (rootView instanceof CordovaWebView) {
		((CordovaWebView)rootView).getView().clearFocus();
	} else if (rootView instanceof ViewGroup) {
		final int childCount = ((ViewGroup)rootView).getChildCount();
		for (int i=0; i< childCount; i++) {
			WikitudePlugin.requestFocusInCordovaWebView(((ViewGroup)rootView).getChildAt(i));
		}
	}
}

But I still want to know are you able to repro it with your phones? I've repro'ed it with android 4.4 and android 7.0 phones. If it repros for every phone, I think it is a defect and deserve a fix.

How do you think?

I find another issue today with the demo app. If I press back button right after exiting from AR, it does not close the app. Press back button again, the app closes. However, if I press anywhere in the AR view before exiting, 1 press of back button is enough to close the app.
I think there's definitely problem in back button handling in the native code.
Folks, have you tried building my repo? Can you repro it?

Eva,

From your reply I'm not sure if you've got my idea. Seems that you're supposing I'm trying to use back button to switch between a web view and an AR view and suggesting me to setup a back button callback.

Actually I'm not trying to switch between them, but only to open and close AR view without affecting the normal behavior of a cordova app. What is happening here is that, after exiting the AR view, a back button press will close the app, instead of navigating to previous page. I fail to understand this move. It looks just like an abnormal exiting to me.

The default behavior of the back button, closing the AR view, is just what I want. I have nothing to do. So I think setBackButtonCallback is irrelevant here.

Did I make it clearer?

BTW, this issue repros both in 5.1.4 and 5.3.0.

Thanks.

Hello Jack,

This issue is already fixed with our SDK version 5.2. What seems to be the problem here is that when you open a web page you are switching the AR view. When you go back then, you should again switch the AR view back to the Wikitude view but for some reason your application fails to do that.


What I could suggest is that you have a look at our sample and see how we are handling things there and see if you are doing anything different from your side. Otherwise you can simply just call the start() again.


Thanks

Eva


 

Login or Signup to post a comment