locked
Unexpectedly iOS Application crashed in Xamarin Forms RRS feed

  • Question

  • User382967 posted

    After Binding the data into CollectionView, the application will crash without any exception,

    The Error Logs are,

    2019-11-16 15:55:42.888725+0530 SampleMobileApp.iOS[48453:5645812] [CollectionView] An attempt to prepare a layout while a prepareLayout call was already in progress (i.e. reentrant call) has been ignored. Please file a bug. UICollectionView instance is (; layer = ; contentOffset: {0, 0}; contentSize: {1, 0}; adjustedContentInset: {0, 0, 0, 0}> collection view layout: ) 2019-11-16 15:55:42.962896+0530 SampleMobileApp.iOS[48453:5645812] * Assertion failure in -[XamarinFormsPlatformiOSGridViewLayout getSizingInfosWithExistingSizingDictionary:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCoreSim/UIKit-3698.140/UICollectionViewFlowLayout.m:1432 2019-11-16 15:55:43.400054+0530 SampleMobileApp.iOS[48453:5645812] Main.cs -> Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: negative sizes are not supported in the flow layout

    at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr nsexception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:406 at ObjCRuntime.Runtime.thrownsexception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:128 at (wrapper native-to-managed) ObjCRuntime.Runtime.thrownsexception(intptr) at (wrapper managed-to-native) ObjCRuntime.Messaging.voidobjcmsgSendSuper(intptr,intptr) at UIKit.UICollectionViewLayout.PrepareLayout () [0x00023] in /Library/Frameworks/Xamarin.iOS.framew ork/Versions/12.14.0.114/src/Xamarin.iOS/UIKit/UICollectionViewLayout.g.cs:571 at Xamarin.Forms.Platform.iOS.ItemsViewLayout.PrepareLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewLayout.cs:440 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/12.14.0.114/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/12.14.0.114/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at SampleMobileApp.iOS.Application.Main (System.String[] args) [0x00002] in D:\Mohan\VS Solutions\SampleMobile_App.iOS\Main.cs:19 --- End of stack trace from previous location where exception was thrown ---

    at (wrapper managed- to-native) ObjCRuntime.Messaging.voidobjcmsgSendSuper(intptr,intptr) at UIKit.UICollectionViewLayout.PrepareLayout () [0x00023] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.114/src/Xamarin.iOS/UIKit/UICollectionViewLayout.g.cs:571 at Xamarin.Forms.Platform.iOS.ItemsViewLayout.PrepareLayout () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ItemsViewLayout.cs:440 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/12.14.0.114/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/12.14.0.114/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at SampleMobileApp.iOS.Application.Main (System.String[] args) [0x00002] in D:\Mohan\VS Solutions\SampleMobileApp.iOS\Main.cs:19 0 CoreFoundation 0x0000000111feb8db __exceptionPreprocess + 331

    My XAML Code is below,

                <CollectionView.ItemsLayout>
                    <GridItemsLayout Orientation="Vertical" Span="3" VerticalItemSpacing="10" HorizontalItemSpacing="10"/>
                </CollectionView.ItemsLayout>
    
                <CollectionView.GroupHeaderTemplate>
                    <DataTemplate>
                        <StackLayout HeightRequest="50" BackgroundColor="{StaticResource BackgroundColour}" HorizontalOptions="FillAndExpand">
                            <Label Text="{Binding ItemsCategoryName,Mode=TwoWay}" Margin="16,0,0,0" TextColor="Black" FontSize="16" VerticalOptions="CenterAndExpand"/>
                        </StackLayout>
                    </DataTemplate>
                </CollectionView.GroupHeaderTemplate>
    
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Frame Margin="0,10,0,0" BackgroundColor="White" CornerRadius="5" BorderColor="LightGray" HeightRequest="150" WidthRequest="100">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Image Grid.Row="1"
                                       Source="{Binding Item_Image}"
                                       HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" 
                                       Aspect="AspectFit"
                                       HeightRequest="75"
                                       WidthRequest="75" />
                                <Label HorizontalOptions="CenterAndExpand" Grid.Row="2"
                                       Text="{Binding Item_Name}"
                                       FontSize="10" TextColor="Black"
                                       LineBreakMode="TailTruncation"/>
                            </Grid>
                        </Frame>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
    

    Saturday, November 16, 2019 10:46 AM

All replies

  • User387013 posted

    The problem might be in your c# code. I had similar exceptions. If you are using SqlLite then there might be parallel calls which will raise an exception. Please check

    Monday, November 18, 2019 7:04 AM
  • User382967 posted

    Yes, But I've not used any SQLite functionalities in my C# Code.

    Tuesday, November 19, 2019 1:58 PM
  • User369979 posted

    It seems you want to create a grouped collection view. What does your items source look like? Did you try to follow this documentation to create the grouped source: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/collectionview/grouping Did you try to test the official sample there? Try to create a collection view sample and upload it here to help me reproduce this issue.

    Wednesday, November 20, 2019 8:09 AM