NSRangeException while loading data

5 posts, 0 answers
  1. Sarvar
    Sarvar avatar
    2 posts
    Member since:
    Oct 2010

    Posted 02 Nov Link to this post

    I am having following error while using native iOS phones (but it is not happening on iPhone Simulator)

    -[TKDataSource itemAtIndex:forSection:]
    NSRangeException: *** -[__NSArrayM objectAtIndexedSubscript:]: index 12 beyond bounds [0 .. 0]

     

    Below is the XAML I am using:

    <telerikDataControls:RadListView Grid.Row="2" VerticalOptions="StartAndExpand" LoadOnDemandMode="Manual"
                        ItemsSource="{Binding Records}"
                        SelectedItem="{Binding SelectedRecord}"
                        IsLoadOnDemandEnabled="true" IsPullToRefreshEnabled="false">
                        <telerikDataControls:RadListView.ItemTemplate>
                            <DataTemplate>
                                 <telerikListView:ListViewTemplateCell>
                                    <telerikListView:ListViewTemplateCell.View>
                                        <Grid>
                                            <StackLayout Spacing="2" Margin="20,5,5,5">
                                                <Label Text="{Binding Title}" FontSize="16" LineBreakMode="TailTruncation" FontAttributes="Bold"  />
                                                <Label Text="{Binding Subtitle}" LineBreakMode="TailTruncation" FontSize="14" TextColor="Gray"  />
                                            </StackLayout>
                                        </Grid>
                                    </telerikListView:ListViewTemplateCell.View>
                                </telerikListView:ListViewTemplateCell>
                            </DataTemplate>
                        </telerikDataControls:RadListView.ItemTemplate>
                        <telerikDataControls:RadListView.LayoutDefinition>
                            <telerikListView:ListViewLinearLayout ItemLength="50" />
                        </telerikDataControls:RadListView.LayoutDefinition>
     </telerikDataControls:RadListView>

     

    Below is the ViewModel.cs which sets Records:

    private ObservableCollection<ViewRecordItem> _records=new ObservableCollection<ViewRecordItem>();
    public ObservableCollection<ViewRecordItem> Records { get => _records; set { _records = value; OnPropertyChanged(); } }
    private async Task Search(bool isNew = true) {
     
               try
               {
                   IsBusy = true;
                   CanRefresh = true;
     
                   if (isNew) _page = 1; else _page++;
     
                   ViewRecordItem[] recs = await svc.GetViewRecordItems(MyViewItem, page: _page, filter: GetFilters());
     
                   if (isNew) Records.Clear();
                   if (recs.Length == 0)
                   {
                       throw new Exception("Search could find any record.");   
                   }
     
                   foreach (var rec in recs)
                   {
                       Records.Add(rec);
                   }
               }
               catch (Exception ex)
               {
                   AlertService.Instance.ShowMsg(ex.Message);
                   CanRefresh = false;
               }
               IsBusy = false;
           }

     

    Below is the crash report from Mobile Center

    CoreFoundation __exceptionPreprocess
    libobjc.A.dylib objc_exception_throw
     
    CoreFoundation _CFThrowFormattedException
    CoreFoundation -[__NSArrayM objectAtIndexedSubscript:]
     
    ExelareMobile.iOS -[TKDataSource itemAtIndex:forSection:]
    ExelareMobile.iOS -[TKDataSource listView:cellForItemAtIndexPath:]
    ExelareMobile.iOS -[TKListView collectionView:cellForItemAtIndexPath:]
     
    UIKit-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:]
    UIKit-[UICollectionView _updateVisibleCellsNow:]
    UIKit-[UICollectionView layoutSubviews]
    UIKit-[UIView(CALayerDelegate) layoutSublayersOfLayer:]
  2. Sarvar
    Sarvar avatar
    2 posts
    Member since:
    Oct 2010

    Posted 03 Nov Link to this post

    This error is not consistent and crashes the app completely, so the exception could not be captured on a Xamarin.Form code. It happens after several successful loads on iPhone 7+ with iOS 11.1

    The Telerik Controls version I am using is: 2017.2.818.234

  3. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    559 posts

    Posted 07 Nov Link to this post

    Hello, Sarvar,

    Thank you for providing the information and the crash report. Unfortunately, it is not sufficient to replicate your exact setup from our end and try to reproduce the issue. Would it be possible to provide a sample so we can further investigate the matter? Furthermore, were you able to replicate the crash or it is only the report from Mobile Center that you have? Does it appear on a certain action(like loading the items) or it is totally random?

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Sarvar
    Sarvar avatar
    1 posts
    Member since:
    Oct 2008

    Posted 07 Nov in reply to Stefan Nenchev Link to this post

    Hi Stefan,

    One of our users consistently has this problem and we were able to track in Mobile Center.

    This problem happens randomly while loading data into RadListView and it cannot be captured by corresponding ViewModel which loads the data from a remote server and assigns it to corresponding property to which RadListView.ItemSource is bound. I was not able to reproduce it on iPhone Simulator or on my iPhone. The issue clearly happens inside iOS project, not inside portable project.

    I don't know if the specifics of my implementation can help to reproduce this issue on your side. Every time I am reloading property bound to RadListView.ItemSource (Records property of type ObservableCollection), I clear it and then add newly obtained results one by one from the array. I have following EventHandler attached to Records, so everytime the number of items in ObservableCollection change, it invokes PropertyChanged event of the ViewModel, which in turn affects RadListView.

    Records.CollectionChanged += (s, o) =>
    {
        OnPropertyChanged("Records");
    };

     

    Please, let me know you received similar issues from other developers and what you recommend to work around this. Thanks.

    Sincerely,

    Sarvar Abdullaev

  5. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    559 posts

    Posted 10 Nov Link to this post

    Hi, Sarvar,

    Thank you for the additional information.

    We have not received any similar reports. I have logged the issue as a bug in our system so we can try to apply a blind fix, if possible, at some point. This way we can also track if someone else reports the behavior and gather more information on the matter. You can track the issue on the following link from our Ideas & Feedback portal - RadListView: [iOS]NSRangeException in TKDataSource itemAtIndex forSection method. Please subscribe to the item in order to receive notifications automatically. Unfortunately, as the issue is not common and we could not easily reproduce it, its priority is not very high and we cannot commit to a time frame when it will be fixed. In case you are able to find more useful information that will help us investigate it, please update the thread or raise a ticket with an example.

    Have a great weekend.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top