Bug 35811 - Navigation.PushAsync from TabbedPage then hit back button causes crash (introduced in
Summary: Navigation.PushAsync from TabbedPage then hit back button causes crash (intro...
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 2.0.0
Hardware: PC Windows
: Normal blocker
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-11-12 10:20 UTC by rjcollingham
Modified: 2017-01-24 19:30 UTC (History)
11 users (show)

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

Solution to reproduce the issue (6.29 MB, application/zip)
2015-11-12 10:20 UTC, rjcollingham
Correct solution (128.98 KB, application/zip)
2015-11-12 16:09 UTC, rjcollingham

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 rjcollingham 2015-11-12 10:20:30 UTC
Created attachment 13786 [details]
Solution to reproduce the issue

Xamarin forms introduced this bug which is still present in Xamarin.Forms Versions of XF before work fine.

Navigating away from a tabbedpage and then hitting the physical back button causes a crash:

{System.InvalidOperationException: Element is already the child of another element.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
   at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at Xamarin.Forms.Platform.WinPhone.Platform.<>c__DisplayClass55.<SetCurrent>b__4d(Object s, EventArgs e)
   at Microsoft.Phone.Controls.Transition.OnCompleted(Object sender, EventArgs e)
   at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)}

I have attached a simple project which shows two tabbed pages. Click the button on the second tabbed page. Then click the physical back button to reproduce the error.

Comment 1 rjcollingham 2015-11-12 16:09:38 UTC
Created attachment 13799 [details]
Correct solution

Sorry wrong solution uploaded previously
Comment 2 Jimmy [MSFT] 2015-11-17 20:04:24 UTC
Marking report as CONFIRMED since I am able to reproduce the crash with the updated sample project and following steps:

1. Launch app and swipe over to "pagetwo"
2. Press "Visit Page Three"
3. Press the hardware back button
Comment 5 Rui Marinho 2016-01-20 11:54:19 UTC
Should be fixed in 2.1.0-pre1
Comment 6 Parmendra Kumar 2016-01-27 14:57:42 UTC
I have checked this issue with Xamarin.Forms and now its working fine.

Hence closing this issue.
Comment 7 Suat Korkmaz 2017-01-24 16:28:36 UTC
Unfortunately I still have this problem.

I'm using XF

On a TabbedPage 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 TabbedPage but everything is frozen. Can't interact with any of the children.

Interestingly, this only happens on Android 5.x devices and 5.x emulators. It works OK on Android 4.x and 6.x devices and emulators.
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2017-01-24 19:30:18 UTC
This exact bug report can be considered closed at this time since it has been marked as resolved for approximately 1 year.  For any appearances of similar issues in versions higher than, please file new bug reports and be sure to include as many details [1] as possible (ideally including a test case).  Thanks in advance!

[1] https://developer.xamarin.com/guides/cross-platform/troubleshooting/questions/howto-file-bug/