Bug 33714 - [WP] Navigating Back Within MasterDetailPage.Detail Causes Crash
Summary: [WP] Navigating Back Within MasterDetailPage.Detail Causes Crash
Alias: None
Product: Forms
Classification: Xamarin
Component: Windows ()
Version: 1.5.0
Hardware: PC Mac OS
: Normal critical
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2015-09-04 19:33 UTC by Jimmy [MSFT]
Modified: 2015-10-15 14:33 UTC (History)
9 users (show)

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

repro project (120.66 KB, application/zip)
2015-09-04 19:33 UTC, Jimmy [MSFT]

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 Jimmy [MSFT] 2015-09-04 19:33:28 UTC
Created attachment 12791 [details]
repro project

*** Overview ***
When a app has an MDPage whose detail is a NavigationPage, navigating back with the back button or PopAsync/PopModalAsync will cause the app to crash with: 

> 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_0.<SetCurrent>b__0(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)}	System.Exception {System.InvalidOperationException}

*** Steps to Reproduce ***
1. Press the menu button and select any item
2. Close the menu
3. Press "Go to more Detail page"
4. Press "Go Back" or the back button

*** Environment Info ***
Microsoft Visual Studio Professional 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Team Explorer for Visual Studio 2013   06177-004-0444002-02323
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02323
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02323
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02323
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02323
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02323
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02323
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

Common Azure Tools   1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

Multilingual App Toolkit   3.1.1250.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://go.microsoft.com/fwlink?linkid=245767

NuGet Package Manager   2.8.60610.756
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Xamarin   3.11.837.0 (f10676f)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (f98871a95a479f6d71b3067b7e5834d41fcb2118)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS (6db87c53c073f4af2f5247fb738a27ea08c094fd)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-09-05 14:16:02 UTC
To help with searchability of this bug: MDPage is an abbreviation for MasterDetailPage.
Comment 2 Thibault Durand 2015-09-08 01:47:21 UTC
This bug does also affect Xamarin.Forms
Comment 3 Jon Goldberger [MSFT] 2015-09-11 16:11:52 UTC
possibly related to bug #32897 and bug #33829
Comment 4 Rui Marinho 2015-09-24 18:30:48 UTC
Should be fixed in 1.5.1-pre1
Comment 5 John Miller [MSFT] 2015-10-02 08:45:55 UTC
Created attachment 13174 [details]
Test Case
Comment 6 John Miller [MSFT] 2015-10-02 08:46:02 UTC
Attaching a new repro project that still has the issue, even when updated to XF 1.5.1-pre1. 

To reproduce:

Open the "not working" sample and update to 1.5.1-pre1. 
Rebuild the projects.
Deploy to the simulator.
Press the Close button. 

The same exception as before.
Comment 7 Eric Maupin 2015-10-15 12:25:15 UTC
Cannot reproduce in 1.5.1-pre2, confirmed with John.
Comment 8 Jason Smith [MSFT] 2015-10-15 14:33:22 UTC
If you are still experiencing and issue, please open a new bug report