Xamarin.forms: [Bug] XamarinForms xaml Hot Reload causing System.ObjectDisposedException: Cannot access a disposed object.

Created on 6 Oct 2020  路  1Comment  路  Source: xamarin/Xamarin.Forms

Description

During debugging, the second time I change a property inside the ProductsListPage xaml in the attached project, an exception is raised and the application crash.

Steps to Reproduce

  1. Open attached project in Visual Studio (OSX)
  2. Debug on iOS Simulator or Actual iOS Device with iOS 14.0
  3. Open ProductsList.xaml
  4. Change a property e.g StackLayout Padding="10,10,10,12"
  5. Save the changes. Hot reload will reflect the changes
  6. Change a property again. e.g. StackLayout Padding="12,10,10,12"
  7. App will crash

Expected Behavior

Hot reload should display the changes

Actual Behavior

Crash with the following

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'GroupableItemsViewController`1'.
at Foundation.NSObject.get_SuperHandle () [0x0004a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/Foundation/NSObject2.cs:401
at UIKit.UIViewController.get_IsViewLoaded () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2147
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.NotLoadedYet () [0x00000] in D:\a\1\sXamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:287
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.ReloadRequired () [0x00000] in D:\a\1\sXamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:292
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.Add (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00023] in D:\a\1\sXamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:163
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x00061] in D:\a\1\sXamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:117
at Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) [0x000b7] in D:\a\1\sXamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:108
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/Foundation/NSAction.cs:178
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/14.0.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at invoices.iOS.Application.Main (System.String[] args) [0x00001] in /Users/yiannis/Projects/Invoices-bug/src/invoices.iOS/Main.cs:17

Basic Information

  • Version with issue: Xamarin.Forms 4.8.0.1451
  • Last known good version:
  • IDE: Visual Studio for Mac Community v8.7.8
  • Platform Target Frameworks:

    • iOS: iOS 14.0 both actual device and simulator

    • Android: working

    • UWP: not tested

  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: iPhone / iPad / Simulator

Screenshots

Screenshot 2020-10-06 at 9 26 11 PM

Screenshot 2020-10-06 at 9 31 12 PM

Reproduction Link

hot-reload-bug.zip

Workaround

VS bug #1226462

collectionview external-hotreload bug

Most helpful comment

@YiannisBourkelis Thanks for the repro sample. Can reproduce the issue.
Captura de pantalla 2020-10-07 a las 13 21 11

>All comments

@YiannisBourkelis Thanks for the repro sample. Can reproduce the issue.
Captura de pantalla 2020-10-07 a las 13 21 11

Was this page helpful?
0 / 5 - 0 ratings