-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xamarin iOS : Crash when i add row to table with nullable type or with a lot of columns #9249
Comments
@Thetyne thanks for reporting this. I have created an issue for this for Xamarin iOS at cc @marek-safar as he has helped with similar issues in the past. |
Note for triage: This is due to a limitation in the number of parameters for methods that are invoked dynamically in the implementation of Xamario.iOS. From @vargaz on the Xamarin issue:
So, it seems that using a smaller value for More details about the limitation:
|
We will add a quirk mode to workaround this issue until it is fixed in Xamarin.iOS. |
For anyone here looking for a quick fix on iOS, I managed to get my project working by pulling EFCore, changing |
@ns-wgilmour When you changed MaxGenericTypes to 14 and 5, did you still see the same failure as reported above? Can you post the exception message and stack trace if there is one? @divega It may not be feasible to go all the way down to 2 generic types. Also, at this level there may be other generics we create that have similar problems. |
@ajcvickers I did, although I only tested it on my current project rather than with the test project I created here to showcase the errors (I catch the errors in that test project, so don't expect it to throw). My current project would crash when trying to do anything related to a particular model with 3 optional relations in it, the keys for which are represented in the model as 3 I think there is slightly more to this problem than meets the eye, or perhaps a misunderstanding of it. @divega, when commenting on the Xamarin issue, said that up to 30 generic arguments could be used, as specified by Also, whilst that particular case seems to be related to generic types, in my test project there is a model with roughly 20 string properties, no I'm not sure if the circumstances are just coincidental but to me there seems to be two different causes. I am unfortunately swamped at the moment so haven't really had time to properly investigate with my test project. I must also confess I know very little about how all this reflection and dynamic invoking generically typed methods works, so my apologies if what I am saying seems nonsensical, I am just trying to put down my observations and thought process. |
I agree we don't understand the limitation in Xamarin.iOS well enough. According to @vargaz it is about the number of arguments on a method that is invoked dynamically. The original repro hit this on the constructor of one of the Hi hope @vargaz has more suggestions here, or information on when the limitation could be lifted. |
@ns-wgilmour maybe you can help us by providing a new repro here and in the Xamarin issue at https://bugzilla.xamarin.com/show_bug.cgi?id=58424. |
The limitation is on the number of arguments to the method which is invoked dynamically. There is no need for another testcase right now. |
@vargaz thanks for responding. We are trying to understand why (according to #9249 (comment)), limiting the number of generic arguments to 14, or even 5 doesn't help. |
Update: mono/mono#5612 will fix this for ARM64 devices in an upcoming release of Xamarin.iOS. |
I tested dynamic invocation on iOS devices. The number of arguments that doesn't throw exception is 3 on ARM64 or 1 on ARMv7. I think To quick fix this problem for ARM64, |
The fixes for this issue have been incorporated in Mono. Not sure what builds of Xamarin will contain it but they are in https://github.com/mono/mono/tree/2017-10. I believe there is nothing actionable on the EF Core side other than validating the fix. Thanks @vargaz! |
Removed the area-external label to repurpose the issue just to validate the fix on our side. |
That's interesting. Are you sure it's the same failure? @brendanzagaeski could you help us to verify this? |
It appears to be. I use long & DateTimeOffset with nullables in this one particular model. I switched everything to int & datetime, now everything works. I'll setup a sample for you hopefully in the next couple of days. |
@divega Can this be moved out of the 2.1 milestone. (We are trying to make 2.1 only include issues that we must fix for 2.1) |
If you guys open up Snapshot.MaxGenericTypes to allow external setting, this issue can be moved entirely to the xamarin iOS team. It is framework bug with them, not with EFCore. |
As @ajcvickers already explained in #9249 (comment) we won’t be making changes for this. We only kept this open for verification purposes, but we have at least one report indicating that this may not be fixed in the 2.1 timeframe. @aritchie I recommend you follow up in the Xamarin issue tracker. I will move this to our backlog for now. |
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) :runtime_invoke_void__this___Guid_Nullable ;-( |
Got this problem as well when using a Devart.SQLite ADO library. To be exact:
This error only comes when I test my app on a physical device though. On emulators everything works like a charm. |
Thats a different problem. |
Still seeing this issue on visual studio version 15.8.1 with xamarin 4.11.0.732 and xamarin.ios 11.14.0.13 |
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! |
@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. |
Also, could you paste the exact error message you are getting, i.e. the {System.ExecutionEngineException: Attempting to JIT compile method |
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. |
I just submitted this as a new issue here. |
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)
Second way : Have a table with a lot of column (here on TrainingExerciseRow with 14 columns)
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)
The text was updated successfully, but these errors were encountered: