efcore: Xamarin iOS : Crash when i add row to table with nullable type or with a lot of columns

Update

According to https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c57, the more complete fix in Mono 2017-12 is now merged and has been verified on Xamarin.iOS.

According to https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c58, the fix should be included in the 15.7 release of Xamarin, which I believe maps to Xamarin.iOS 11.9 (at least I found that on https://github.com/xamarin/xamarin-macios/wiki).

Original issue

EntityFramework crash when i insert a row inside table. it crash only on iOS Device (iPod Touch and iPad mini 4).

I have try successfully onAndroid Device and iOS Simulator. But when i use on iOS device, it fall to Xamarin iOS limitation.

First way : when i have a nullable type inside TrainingDayRow table (exemple : int? unit)

Exception message: 
Stack trace:

{System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___object_int_int_int_int_DateTime_DateTime_DateTime_Nullable`1<int> (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.14/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
 --- End of stack trace from previous location where exception was thrown ---

Second way : Have a table with a lot of column (here on TrainingExerciseRow with 14 columns)

Exception message: 
Stack trace:

{System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___object_int_int_int_int_DateTime_DateTime_DateTime_int (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
 at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.14/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
--- End of stack trace from previous location where exception was thrown ---

Steps to reproduce

Clone my Github source and just click to “+”.

Source code https://github.com/Thetyne/XamarinTodo

Further technical details

EntityFrameworkCore 2.0.0-preview2-final NetStandard 2.0.0.0-preview2-25401-01 Database Provider: Microsoft.EntityFrameworkCore.Sqlite Operating system: iOS/Macosx IDE: Visual Studio Community 2017 for Mac Version 7.1 Preview (7.1 build 1281)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 44 (18 by maintainers)

Most upvoted comments

I just submitted this as a new issue here.

After digging in a bit more, I have been able to isolate that the problem only occurs when there is a column of type Nullable Guid (Guid?). With this configuration I was able to get it working on a physical device with a table consisting of 20+ columns and including Nullable DateTime? and int? types, but throwing a Guid? column into the mix causes this error.

As @divega suggests, I will submit this as a new issue. In the meantime if anyone has ideas for workarounds, I would love to hear them.

Like @Kelsch, I am still seeing the problem with the latest VS and Xamarin versions. I am using EF Core 2.1.2, and would be willing to try the EF Core 2.2 preview, but at this point, it is unclear to me where the problem resides. Is this a VS issue, Xamarin.iOS issue, or an EF Core issue? Until today, I have not been able to test because I kept running a compile error (described here) that prevented me from running on a physical iOS device. It appears that was resolved with VS 15.8.x.

Any information is much appreciated!

I tried today with Visual Studio 15.7.2, Xamarin.Forms 3.0.0.482510, Xamarin.iOS 11.10.1.178 - still no luck…

[0:] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ExecutionEngineException: Attempting to JIT compile method ‘(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___Guid_Nullable1<Guid>_object_object_double_int_single_object_object_object_object_Nullable1<Guid>_object_DateTime_Nullable`1<DateTime> (object,intptr,intptr,intptr)’ while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

😭

@msangtarash It is not intended that the value for MaxGenericTypes be changed. Setting it to pathologically low numbers also largely defeats the purpose of the design. Also, there are likely other places that will fail for similar reasons if the underlying bug is not fixed, so I think there needs to be a very strong case to change this as oppose to getting the underlying bug fixed.

We will add a quirk mode to workaround this issue until it is fixed in Xamarin.iOS.

Thank you for following up. I will post a new issue asap. For now, here is a screenshot of the error I am getting on an iPhone 7 when attempting to add a record to a table with the the following column types (8 total):

  • Guid
  • string
  • DateTime
  • Guid?
  • DateTime
  • DateTime?
  • int?
  • string

img_0042

@Kelsch @cfdelaune I am sorry to hear that this isn’t fixed for you in recent releases of Xamarin. If you are seeing the exact same symptoms described here, it is mostly likely still a Xamarin issue. I know that the Xamarin team has made several fixes trying to address this, but perhaps there is one more case that they need to look at.

If you haven’t already, please report it by creating a new issue on Xamarin’s new issue tracker at https://github.com/xamarin/xamarin-macios/issues. You can mention that you believe this is similar to https://bugzilla.xamarin.com/show_bug.cgi?id=58424 and https://bugzilla.xamarin.com/show_bug.cgi?id=59184, but please also include a repro project so that they can investigate why the fixes already included in the product aren’t helping.

Also, feel free to @ mention me in the issue so I can follow up with the Xamarin team.

cc @marek-safar, @vargaz , @mandel-macaque

15.7 preview 1 should go out today with the final version (RTW) to be somewhere around 10th of May

Update: According to https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c57, the more complete fix in Mono 2017-12 is now merged and has been verified on Xamarin.iOS.

According to https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c58, the fix should be included in the 15.7 release of Xamarin, which I believe maps to Xamarin.iOS 11.9 (at least I found that on https://github.com/xamarin/xamarin-macios/wiki).

I am not sure about the timing of that release. @marek-safar do you have any schedule information you can share?