sqlite-net: Not working on iOS after 1.8.116 - Attempting to JIT compile method '(wrapper delegate-invoke)

Steps to reproduce:

  1. Create Xamarin.iOS application
  2. Create SQLAsyncConnection
  3. Access Entity via Table<T>().FindOneAsync

Error:

Attempting to JIT compile method ‘(wrapper delegate-invoke) void <Module>:invoke_callvirt_void_UserInfo_Guid (Skandy.Mobile.Domain.UserInfo,System.Guid)’ while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information. ; Version: 1.6.408. iOS: 8C36CE78-3988-40D7-9CDB-54BF1677E694 at SQLite.FastColumnSetter+<>c__DisplayClass2_02[ObjectType,ColumnMemberType].<CreateTypedSetterDelegate>b__0 (System.Object o, SQLitePCL.sqlite3_stmt stmt, System.Int32 i) <0x1059bd710 + 0x00187> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.SQLiteCommand+<ExecuteDeferredQuery>d__121[T].MoveNext () <0x1059e7ec4 + 0x0031f> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at System.Collections.Generic.List1[T].AddEnumerable (System.Collections.Generic.IEnumerable1[T] enumerable) <0x104f40934 + 0x000b3> in <da8885cdf78b449d96de00cdb9d47225#a6464d95a03c7bacba393abaab79514c>:0 at System.Collections.Generic.List1[T]..ctor (System.Collections.Generic.IEnumerable1[T] collection) <0x104f3e330 + 0x00193> in <da8885cdf78b449d96de00cdb9d47225#a6464d95a03c7bacba393abaab79514c>:0 at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) <0x105652e54 + 0x00093> in <26bd496943a145e18f2cd8379c502c52#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.SQLiteCommand.ExecuteQuery[T] () <0x1059e64b4 + 0x00073> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.TableQuery1[T].ToList () <0x1059efeb0 + 0x00063> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.TableQuery1[T].FirstOrDefault () <0x1059f0084 + 0x0002b> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.SQLiteConnection.Find[T] (System.Linq.Expressions.Expression1[TDelegate] predicate) <0x1059dd4a4 + 0x00047> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.SQLiteAsyncConnection+<>c__DisplayClass70_01[T].<FindAsync>b__0 (SQLite.SQLiteConnectionWithLock conn) <0x1059f5a88 + 0x00047> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at SQLite.SQLiteAsyncConnection+<>c__DisplayClass32_01[T].<ReadAsync>b__0 () <0x1059f4b14 + 0x0006f> in <01c96d411fe34bd5940c99a56515582b#a6464d95a03c7bacba393abaab79514c>:0 at System.Threading.Tasks.Task`1[TResult].InnerInvoke () <0x104e432a8 + 0x000bb> in <da8885cdf78b449d96de00cdb9d47225#a6464d95a03c7bacba393abaab79514c>:0 at System.Threading.Tasks.Task.Execute () <0x104e4796c + 0x00023> in <da8885cdf78b449d96de00cdb9d47225#a6464d95a03c7bacba393abaab79514c>:0 —

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 24
  • Comments: 32 (5 by maintainers)

Most upvoted comments

Any news on this?

There has been no response on this so I’ll share my diagnosis: FastColumnSetter was added 2 years ago in the code.
2 months ago PR #1059 was committed to the codebase. In that PR a line was added to use MakeGenericMethod. This is fine for anywhere that JIT is allowed, but on iOS if you have Link All Assemblies set (Release Mode) then it cannot work because it needs to create some code for the generics in question. This is not allowed in AOT mode on iOS.

https://stackoverflow.com/questions/24588090/makegenericmethod-makegenerictype-on-xamarin-ios

@praeclarum Any thoughts about this?

@stoff99 I have not checked this “workaround” because a) it is tedious to test since it only occurs on device, not while debugging etc. b) I am busy with other stuff, but mainly since c) it does not address the actual bug/issue.

Others will come after us, use MAUI/Xamarin and SQLite with default settings and latest versions, and not having found this thread, and their app will not work/break in production.

Thanks for posting this guys. Totally saved my sanity!!

I have exactly this issue and rolling back to 1.7.335 works for me. Thanks @Hottemax for the [ ] trick.

With Visual Studio 2022 17.1 AOT and Interpreter work now. So this can used as a workaround too. image

About the apple review: I sent in the app to the apple review and it was accepted without any problems.

Yeah, this works at the moment without problems. But I hope, this bug will fix as soon as possible.

Wondering whether this will ever be adressed. This is pretty weird since

a) developer (@praeclarum) seems to have moved on to other projects or at least this project is not a priority. This is their prerogative, they have no obligation at all and I am thankful that they have built this library at all. b) Microsoft at the same time is pushing out content with MAUI that presents sqlite-net-pcl as a standard, mature and viable option for data storage. For example

This error still occurs in Xamarin.Forms as well as MAUI for us, about a year after it first appeared. Currently, we are fixing our nuget dependency in csproj with square brackets like this

<!--Set to 1.7.335 due to https://github.com/praeclarum/sqlite-net/issues/1067 -->
<PackageReference Include="sqlite-net-pcl" Version="[1.7.335]" />

Will there ever be a resolution to this?

The existing PR doesn’t really fix the problem, it just pushes the optimization of the generated run-time compiled code onto the consumer programmer. Maybe there is a way to compromise where the performance is increased but there doesn’t need to be run-time compiled code. Try to generate code, if the platform doesn’t support it fail over to the old way. Or maybe some way of providing a generic method on your class that will set the property without boxing.

We experience this issue too using FirstOrDefaultAsync:

image

await Database.Table<T>().FirstOrDefaultAsync()