Bug 29344 - TableView Collection was modified enumeration operation may not execute
Summary: TableView Collection was modified enumeration operation may not execute
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: 1.4.2
Hardware: PC Mac OS
: Normal critical
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-23 12:17 UTC by John Miller [MSFT]
Modified: 2015-06-17 13:37 UTC (History)
2 users (show)

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


Attachments
Test Case (1.71 MB, application/zip)
2015-04-23 12:17 UTC, John Miller [MSFT]
Details


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:
VERIFIED FIXED

Description John Miller [MSFT] 2015-04-23 12:17:53 UTC
Created attachment 10880 [details]
Test Case

**Overview:**

   Touching multiple EntryCells in a TableView while the Keyboard is open eventually causes a crash. 

**Steps to Reproduce:**

   1. Run the attached FormsGallery sample on an iOS Simulator
   2. Touch the "TableView for a form" row
   3. Touch an EntryCell to show the keyboard
   4. Scroll and touch other EntryCells
   5. Occasionally touch the Label of the EntryCell (caption text)
   6. Repeat step 4-5 until it crashes

   The above is sort of strange, so here is a video showing how I reproduced this: http://screencast.com/t/t1Pbln1KZ

**Actual Results:**

   2015-04-23 12:15:09.350 FormsTemplateiOS[22510:4058501] Unhandled managed exception: Collection was modified; enumeration operation may not execute. (System.InvalidOperationException)
  at System.Collections.Generic.List`1+Enumerator[System.Tuple`2[System.WeakReference,System.Action`2[System.Object,System.Object]]].MoveNext () [0x00063] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.Generic/List.cs:815 
  at Xamarin.Forms.MessagingCenter.InnerSend (System.String message, System.Type senderType, System.Type argType, System.Object sender, System.Object args) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.MessagingCenter.Send[IVisualElementRenderer] (IVisualElementRenderer sender, System.String message) [0x00000] in <filename unknown>:0 
  at Xamarin.Forms.Platform.iOS.TableViewModelRenderer.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46 
  at FormsGallery.iOS.Application.Main (System.String[] args) [0x00008] in /Users/johnmiller/Downloads/xamarin-forms-samples-master/FormsGallery/FormsGallery/FormsGallery.iOS/Main.cs:17 
2015-04-23 12:15:09.351 FormsTemplateiOS[22510:4058501] critical: Stacktrace:

**Expected Results:**

   No crash.

**Build Date & Platform:**

   XF 1.4.2
   XI 8.9
Comment 1 Jason Smith [MSFT] 2015-05-20 21:07:20 UTC
Interesting catch:

For whoever ends up fixing this the offending line in the MessagingCenter is:

foreach (var action in actions) {

Should actually be:

foreach (var action in actions.ToList ()) {

or some cheaper equal.
Comment 2 Jason Smith [MSFT] 2015-05-20 21:09:03 UTC
For further reference, the issue is a callback from the MessagingCenter is causing either a sub or unsub to the offending message, thus invalidating the list. Proper behavior would need to ensure things that unsub mid processing loop dont end up getting the event.
Comment 3 Jason Smith [MSFT] 2015-06-01 12:17:21 UTC
This should be fixed in 1.4.3 final
Comment 4 Parmendra Kumar 2015-06-17 13:37:13 UTC
I have checked this issue with xamarin.forms.1.4.3.6364-pre3 and its working fine at my end.

Hence closing this issue.

Environment info:

Xamarin Studio  5.9.3 (build 1)
Mono 4.0.1 ((detached/ed1d3ec)
GTK+ 2.24.23 (Raleigh theme)
Package version: 400010044
Xcode 6.2 (6776)
Xamarin.iOS 8.10.1.64 (Enterprise Edition)
Xamarin.Android 5.1.3.1 (Enterprise Edition)
Xamarin.Mac : 2.0.1.64 (Enterprise Edition)
Mac OS X 10.9.4