Bug 51806 - Navigation.PushAsync causing failure when using FormsAppCompatActivity
Summary: Navigation.PushAsync causing failure when using FormsAppCompatActivity
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-01-27 06:13 UTC by Suat Korkmaz
Modified: 2017-01-31 22:10 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Sample project for the bug (43.96 KB, application/x-zip-compressed)
2017-01-27 06:13 UTC, Suat Korkmaz

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Suat Korkmaz 2017-01-27 06:13:35 UTC
Created attachment 19503 [details]
Sample project for the bug

### Overview
On a page when I do:

    await Navigation.PushAsync(new ContentPage());

It displays a blank ContentPage (as expected) but when I hit the back button it goes back to the previous page but everything is frozen. Can't interact with any of the children.

Interestingly, this only happening on Android 5.x devices and 5.x emulators. It works OK on Android 4.x and 6.x devices and emulators.

### Steps to Reproduce
1- Create a portable project.
2- Add nothing to Droid project. Droid MainActivity will be a FormsAppCompatActivity
3- Create a TabbedPage and load it as MainPage
MainPage = new NavigationPage(new MyTabbedPage());
4- Add 2 ContentPage to MyTabbedPage as children.
5- Add a Button to the ContentPage and in its clicked event navigate away to somewhere.
await Navigation.PushAsync(new ContentPage());
6- Hit the back button and try to interact to the tabs and/or try to scoll. That's where its freezing.

NOTE: Sample App attached
Comment 1 Jimmy [MSFT] 2017-01-27 22:24:05 UTC
I can reproduce the issue described with the attached project.

However I cannot reproduce it with a new project, even when using the steps provided. And if I add a new Android project to the original solution and reference the same PCL, I do _not_ experience the issue. 

There are couple of differences I noticed between the attached project and a new project when running the app that make me think there is something different with the original Android project that is causing this:

1. Performance with the original project is worse and scrolling through a list with the same number items is sluggish compared to a new project

2. After navigating to another page and pressing and holding the back arrow in the navigation bar in the original project, the Android 'bubble' effect will be clipped by the button's bounds. In a new project, the bubble expands past the bounds and is completely visible.

I am still marking this as confirmed since I can repro it, however more investigation is necessary to determine if this is a Forms bug.
Comment 2 Suat Korkmaz 2017-01-29 18:27:06 UTC
Thanks Jimmy.

I agree all. I cannot reproduce the it when I create a new project. However I cannot find the difference when I compare ALL the files one by one. The original project and the new is completally equal.

I wrote some code to walkaround and it works but as you said it has performance issues and I know this and the original failure is caused by the same problem (or bug, I don't now.)

My app is on the store now and I need to figure what causes the fail. I've been trying to find the root of the problem for a week without any luck. Honestly I expect from you a litle hand to get this solved.
Comment 3 Suat Korkmaz 2017-01-31 08:50:45 UTC
I finally found the bug after thousands of trial.

In AndroidManifest.xml file when you do:

<application android:label="BuggyProject.Droid"></application>
<uses-sdk android:minSdkVersion="15" />

It doesn't work.

But when you shift these two lines like:

<uses-sdk android:minSdkVersion="15" />
<application android:label="BuggyProject.Droid"></application>

It works as it should be.

I still don't know if this is a bug or not but I can't believe this took my 2 weeks to solve.
Comment 4 Jimmy [MSFT] 2017-01-31 22:10:06 UTC
According to Google's documentation[1], the <application> element must be the _last_ element in the AndroidManifest.xml file. Since <uses-sdk> was last instead, this is most likely what was causing the issue though it is still uncertain as to why since Google does not explain this.

I've filed an enhancement request for the manifest file to be verified during building in order to prevent this: bug #52164

[1] [1] https://developer.android.com/guide/topics/manifest/manifest-intro.html#filec