Bug 29769 - Clearing CarouselPage Children after OnAppearing throws exception on iOS
Summary: Clearing CarouselPage Children after OnAppearing throws exception on iOS
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.2
Hardware: Macintosh Mac OS
: High critical
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on: 60966
Blocks:
  Show dependency tree
 
Reported: 2015-05-05 16:05 UTC by tim.ahrentlov
Modified: 2017-12-11 23:03 UTC (History)
8 users (show)

Tags: crash, carouselpage, dispose, ac, retest
Is this bug a regression?: ---
Last known good build:


Attachments
Test case to reproduce bug (64 bytes, text/plain)
2015-05-05 16:06 UTC, tim.ahrentlov
Details
Zip Xamarin Logs (823.66 KB, application/octet-stream)
2015-05-06 06:19 UTC, Sadik Ali
Details


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 for Bug 29769 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description tim.ahrentlov 2015-05-05 16:05:50 UTC
Clearing the CarouselPage Children list after it's OnAppearing event has been fired once, throws an "The object was used after being disposed." exception on iOS. I have not tried android. 

To reproduce download test case and run it.

Then:

1. Click Menu.
2. Click Detail 2.
3. Click Menu.
4. Click Detail 1.

The exception has now been cast.
Comment 1 tim.ahrentlov 2015-05-05 16:06:24 UTC
Created attachment 11072 [details]
Test case to reproduce bug
Comment 2 tim.ahrentlov 2015-05-05 16:08:28 UTC
I should mention that RemovePage throws the same exception
Comment 3 tim.ahrentlov 2015-05-06 03:39:43 UTC
1.4.3 - pre2 exhibits the same error
Comment 4 Sadik Ali 2015-05-06 06:18:26 UTC
I have checked this issue and able to reproduce the above behavior with the help of sample and steps given in the bug description.I checked this issue using Xamarin.Forms 1.4.3.6358-pre2.

Screencast: http://www.screencast.com/t/Tc8Srl9UNi
Debug Output: https://gist.github.com/Shruti360/f2177e8e20eb88e0c356
MTBServer Logs: https://gist.github.com/saurabh360/ef9b0848accf91dce682
System Logs: https://gist.github.com/saurabh360/773ba561b5f7a485d81d

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.50938

Installed Version: Professional

Xamarin   3.11.504.0 (37bb34c)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   5.1.0.127 (cbdf025e886eacb95ce7adf53346961156fae990)
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   8.10.0.0 (7741cc495ab0baf04ff0405d0604bc27f0ecae2e)
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

Xamarin.iOS: 8.10.1.28
Build Host: 3.11.0.446
Comment 5 Sadik Ali 2015-05-06 06:19:19 UTC
Created attachment 11085 [details]
Zip Xamarin Logs
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2015-05-14 02:38:58 UTC
Thanks for the test case!


In case it might be helpful for the Xamarin.Forms team, I tried a quick experiment where I modified the test case to avoid any use of `OnAppearing()` or the `Appearing` event. As a replacement, I added another button in the StackLayout:

> new Button()
> {
>     Text = "Add",
>     Command = new Command(() => { ((CarouselPage)((NavigationPage)mdPage.Detail).CurrentPage).Children.Add(NewContentPage(0)); }),
>     HorizontalOptions = LayoutOptions.Start
> }


If I then navigated to "Detail 2", then back to "Detail 1", and then clicked the "Add" button, I hit the same "The object was used after being disposed." as in the original test case.
Comment 7 tim.ahrentlov 2015-05-15 05:33:13 UTC
I appears that then used as the MasterDetail Detail page - albeit wrapped in a Navigation Page - the CarouselPage children are forcefully disposed of when a new Detail page is set. 

Thus, when you return to the former Carousel Page, the children are in an unknown state.   

I've rewritten my code to create a new Carousel Page whenever the Detail page is revisited. Not exactly efficient (trademark of the current XF engine) , but it avoids the reported section.