Bug 38449 - Issues with adding ListView items (only in iOS)
Summary: Issues with adding ListView items (only in iOS)
Status: RESOLVED NORESPONSE
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-02-04 12:32 UTC by Olexandr Mykhailov
Modified: 2017-02-24 15:56 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Olexandr Mykhailov 2016-02-04 12:32:47 UTC
I'm trying to get a ListView to display with infinite scrolling: when last item appearing i load data to binded observablecollection source.

My observable collection has next implementation:
public class ObservableCollectionFast : ObservableCollection where T : class
{
 public void AddRangeBottom(IList range)
 {
    var startIndex = Items.Count;
    foreach (var item in range)
    {
      Items.Insert(Items.Count, item as T);
    }
      OnPropertyChanged(new PropertyChangedEventArgs("Count"));
      OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
      OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, range, startIndex));
 }
}

Very often when I load data I have crashes in iOS with the next stack:

Unhandled Exception:

Foundation.MonoTouchException: Objective-C exception thrown. Name: NSRangeException Reason: *** -[NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]
 Native stack trace:
 0 CoreFoundation 0x08471a94 __exceptionPreprocess + 180
 1 libobjc.A.dylib 0x087dbe02 objc_exception_throw + 50
 2 CoreFoundation 0x0833deb3 -[__NSArrayM objectAtIndex:] + 243
 3 UIKit 0x01174ee5 -[UITableView visibleCellForGlobalRow:] + 60
 4 UIKit 0x014ae0e9 -[_UITableViewUpdateSupport(Private) _setupAnimationsForExistingVisibleCells] + 635
 5 UIKit 0x014bb616 -[_UITableViewUpdateSupport _setupAnimations] + 125
 6 UIKit 0x0114bc77 -[UITableView _updateWithItems:updateSupport:] + 3653
 7 UIKit 0x011439b8 -[UITableView _endCellAnimationsWithContext:] + 17491
 8 UIKit 0x0115da73 -[UITableView endUpdatesWithContext:] + 51
 9 UIKit 0x0115daa1 -[UITableView endUpdates] + 41
 10 ??? 0x19c7dc04 0x0 + 432528388
 11 ??? 0x25e19298 0x0 + 635540120
 12 ??? 0x25ddee26 0x0 + 635301414
 13 ??? 0x25ddeb1c 0x0 + 635300636
 14 ??? 0x19f6f14a 0x0 + 435614026
 15 ??? 0x19f6eae4 0x0 + 435612388
 16 ??? 0x19f6cf24 0x0 + 435605284
 17 ??? 0x25ddea72 0x0 + 635300466
 18 ??? 0x25dde9f4 0x0 + 635300340
 19 ??? 0x25dde02d 0x0 + 635297837
 20 ??? 0x25dddb90 0x0 + 635296656
 21 ??? 0x19c4c98c 0x0 + 432327052
 22 ??? 0x25e170d0 0x0 + 635531472
 23 ??? 0x25e16cfc 0x0 + 635530492
 24 ??? 0x19e14ed9 0x0 + 434196185
 25 ??? 0x17acfaa6 0x0 + 397212326
 26 HubberiOS 0x001878f3 mono_jit_runtime_invoke + 707
 27 HubberiOS 0x0023da8f mono_runtime_invoke + 127
 28 HubberiOS 0x00086c91 _ZL30native_to_managed_trampoline_3P11objc_objectP13objc_selectorPP11_MonoMethodPKcS7 + 257
 29 HubberiOS 0x00098aea -[__MonoMac_NSAsyncActionDispatcher xamarinApplySelector] + 74
 30 libobjc.A.dylib 0x087f0059 -[NSObject performSelector:withObject:] + 70
 31 Foundation 0x00b336e8 __NSThreadPerformPerform + 323
 32 CoreFoundation 0x0838be7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
 33 CoreFoundation 0x08381aa8 CFRunLoopDoSources0 + 424
 34 CoreFoundation 0x08380f28 __CFRunLoopRun + 1032
 35 CoreFoundation 0x08380866 CFRunLoopRunSpecific + 470
 36 CoreFoundation 0x0838067b CFRunLoopRunInMode + 123
 37 UIFoundation 0x0bb28211 -[NSHTMLReader _loadUsingWebKit] + 2469
 38 UIFoundation 0x0bb28b7c -[NSHTMLReader _load] + 212
 39 UIFoundation 0x0bb2982b -[NSHTMLReader attributedString] + 35
 40 UIFoundation 0x0bab7c78 _NSReadAttributedStringFromURLOrData + 5742
 41 UIFoundation 0x0bab6570 -[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 137
 42 ??? 0x19fd7364 0x0 + 436040548
 43 ??? 0x19fd700c 0x0 + 436039692
 44 ??? 0x19fd6e10 0x0 + 436039184
 45 ??? 0x19fd6d58 0x0 + 436039000
 46 ??? ... 0x19dc30da 0x0 + 433860826
 139 ??? 0x19db5c7a 0x0 + 433806458
 140 ??? 0x19db5518 0x0 + 433804568
 141 ??? 0x25df2809 0x0 + 635381769
 142 ??? 0x25df23d4 0x0 + 635380692
 143 ??? 0x25df2264 0x0 + 635380324
 144 ??? 0x1e8400ae 0x0 + 511967406
 145 ??? 0x25de0128 0x0 + 635306280
 146 ??? 0x1e83f865 0x0 + 511965285
 147 HubberiOS 0x001878f3 mono_jit_runtime_invoke + 707
 148 HubberiOS 0x0023da8f mono_runtime_invoke + 127
 149 HubberiOS 0x0030d696 xamarin_trampoline + 5734
 150 UIKit 0x01176b91 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 782
 151 UIKit 0x01176cbf -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
 152 UIKit 0x01146518 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3317
 153 UIKit 0x01166716 __29-[UITableView layoutSubviews]_block_invoke + 52
 154 UIKit 0x01180a18 -[UITableView _performWithCachedTraitCollection:] + 88
 155 UIKit 0x01166684 -[UITableView layoutSubviews] + 214
 156 UIKit 0x010be16b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 813
 157 libobjc.A.dylib 0x087f0059 -[NSObject performSelector:withObject:] + 70
 158 QuartzCore 0x0350d60c -[CALayer layoutSublayers] + 144
 159 QuartzCore 0x0350128e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
 160 QuartzCore 0x035010f2 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
 161 QuartzCore 0x034f3c2b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
 162 QuartzCore 0x03527c23 _ZN2CA11Transaction6commitEv + 589
 163 QuartzCore 0x03529484 _ZN2CA11Transaction17flush_transactionEv + 50
 164 QuartzCore 0x03538a5f _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 593
 165 QuartzCore 0x03538ec5 _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 123
 166 CoreFoundation 0x083c3686 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 22
 167 CoreFoundation 0x083c3082 __CFRunLoopDoTimer + 1250
 168 CoreFoundation 0x083813ba __CFRunLoopRun + 2202
 169 CoreFoundation 0x08380866 CFRunLoopRunSpecific + 470
 170 CoreFoundation 0x0838067b CFRunLoopRunInMode + 123
 171 GraphicsServices 0x09a4d664 GSEventRunModal + 192
 172 GraphicsServices 0x09a4d4a1 GSEventRun + 104
 173 UIKit 0x00ff8cc1 UIApplicationMain + 160
 174 ??? 0x18899d78 0x0 + 411671928
 175 ??? 0x18899b70 0x0 + 411671408
 176 ??? 0x17af1c80 0x0 + 397352064
 177 ??? 0x17af1810 0x0 + 397350928
 178 ??? 0x17af1b48 0x0 + 397351752
 179 HubberiOS 0x001878f3 mono_jit_runtime_invoke + 707
 180 HubberiOS 0x0023da8f mono_runtime_invoke + 127
 181 HubberiOS 0x002427a1 mono_runtime_exec_main + 401
 182 HubberiOS 0x00242565 mono_runtime_run_main + 629
 183 HubberiOS 0x0011011d mono_jit_exec + 93
 184 HubberiOS 0x0031bca1 xamarin_main + 2497
 185 HubberiOS 0x000d0661 main + 113
 186 libdyld.dylib 0x09178a21 start + 1
Comment 1 Rolf Bjarne Kvinge [MSFT] 2016-02-04 13:28:49 UTC
Are you using Xamarin.Forms?
Comment 2 Olexandr Mykhailov 2016-02-04 14:03:27 UTC
Yes I am. Xamarin.Forms 2.0.1.6505.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2016-02-04 14:21:49 UTC
Reassigning.
Comment 4 Rui Marinho 2016-12-20 23:11:15 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.  


For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d  

Warm regards, 

Xamarin Forms Team
Comment 5 Paul DiPietro [MSFT] 2017-02-24 15:56:41 UTC
No response has been provided for well over 60 days and as such I am closing this ticket. Please reopen with a minimized reproduction project if the issue still exists.