ListView with Hot Reload crashes on iOS
See original GitHub issueNot sure if this is an underlying MAUI problem, but ListView crashes on iOS after saving a couple of times with Hot Reload enabled.
Make a ProductItem change, save a couple of times. See it crash.
dotnet build -t:Run -f net7.0-ios /p:_DeviceName=:v2:udid=EECA5B10-A549-4D07-8A60-0CA944B62766
dotnet-maui-reactor -f net7.0-ios
Unhandled Exception:
System.InvalidCastException: Specified cast is not valid.
at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle)
at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName)
at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
at OrderingApp.Program.Main(String[] args)
Made the following changes to the OrderingApp:
- Updated to 1.0.33
- In MainPage, changed CollectionView to ListView (commented out Scroll related code). see portion of changed code below:
:
:
class MainPage : Component<MainPageState>
{
private MauiControls.ListView? _listView;
public override VisualNode Render()
{
return new ContentPage
{
new Grid("260, *", "*")
{
new Header()
.SelectedType(State.SelectedType)
.OnTypeSelected(productType => OnSelectedType(productType, true)),
new ListView(Microsoft.Maui.Controls.ListViewCachingStrategy.RecycleElementAndDataTemplate, listView => _listView = listView)
.HasUnevenRows(true)
.ItemsSource(ProductItem.Items, RenderProductItem)
// .OnScrolled(OnListViewScrolled)
.GridRow(1)
.Margin(24,20),
new Cart()
.Item(State.SelectedItemIndex == null ? null : ProductItem.Items[State.SelectedItemIndex.Value])
.OnClose(()=>SetState(s => s.SelectedItemIndex = null))
.GridRowSpan(2)
}
};
}
private ViewCell RenderProductItem(ProductItem item)
{
return new ViewCell
{
new Border
{
new Grid("*", "115,*")
{
new Image($"{item.Image}.png")
.HeightRequest(140)
.WidthRequest(140)
.TranslationX(-20)
,
new Grid("20,*,24", "*")
{
new Label(item.Title)
.FontFamily("MulishSemiBold")
.FontSize(18)
.VStart()
.TextColor(Colors.Black),
new Label(item.Description)
.FontFamily("MulishRegular")
.FontSize(12)
.VCenter()
.TextColor(Color.FromArgb("#121212"))
.GridRow(1),
new Label($"${item.Cost}")
.FontFamily("MulishSemiBold")
.FontSize(16)
.VStart()
.TextColor(Colors.Black)
.GridRow(2),
}
.GridColumn(1)
.Margin(12,15),
new Border
{
new Label("+ ADD")
.FontFamily("MulishBold")
.TextColor(Colors.White)
.VCenter()
.HCenter()
}
.OnTapped(()=>SetState(s => s.SelectedItemIndex = ProductItem.Items.IndexOf(item)))
.WidthRequest(78)
.HeightRequest(34)
.BackgroundColor(Theme.PrimaryColor)
.StrokeShape(new RoundRectangle().CornerRadius(13,0,0,13))
.GridColumn(1)
.HEnd()
.VEnd()
}
}
.StrokeShape(new RoundRectangle().CornerRadius(13))
.Background(new MauiControls.LinearGradientBrush(new MauiControls.GradientStopCollection
{
new MauiControls.GradientStop(Theme.PrimaryLightColor, 0.0537f),
new MauiControls.GradientStop(Colors.White, 0.9738f)
},
new Point(0, 0.5),
new Point(1, 0.5)))
.Margin(0,0,0,12)
.HeightRequest(132)
};
}
:
:
}
Issue Analytics
- State:
- Created 3 months ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
[Bug] HotReload ListView crash into iOS when ViewCell ...
When use hot reload to see changes using ListView it crash on iOS and Android not update correctly, when ViewCell is present into...
Read more >List view crashes on ios when pull to refresh in UI for Xamarin
Following list view I am implementing pull to refresh and set the Itemsource by adding more items to the current list when the...
Read more >Setting ItemSource for ListView crashes on iOS, works fine ...
I'm creating an App using Xamarin Forms where the HomePage has a ListView inside of the main StackLayout . Grouping is enabled in...
Read more >Hot Reload freezes VS Mac with virtualized ListViews
The issue is this: if you have Hot Reload with Changes Only mode and a virtualized ListView in the screen (XF 5+), thousands...
Read more >hot reload crashes on collectionview - Developer Community
I'm getting the following crash after editing a xaml file containing a collectionview ``` System.ObjectDisposedException: Cannot access a disposed object.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m going to close this issue because from what I can see now it’s something not related to MauiReactor, feel free to continue commenting if you find anything I can help on
@adospace may be the crashes are related to this https://github.com/dotnet/maui/issues/11203 - fixed in .net 8.0-preview1