Skip to content
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

SQLite in iOS with Maui crashes when the app is published on the store #1227

Open
erossini opened this issue Jun 2, 2024 · 7 comments
Open

Comments

@erossini
Copy link

erossini commented Jun 2, 2024

In my NET8 MAUI application, I use SQLite and here are the packages I added to the project.

<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.1.8" />
<PackageReference Include="SQLitePCLRaw.provider.sqlite3" Version="2.1.8" />

The application reads the database quite often. In debug, the application runs normally without errors. When I published the application on the Apple store, when the app reads the database, the application crashed immediately. I can see the error in the AppCenter

SIGABRT: Attempting to JIT compile method '(wrapper delegate-invoke) void System.Action`2<LanguageInUse.Domain.Dictionary, System.DateTime>:invoke_callvirt_void_T1_T2 (LanguageInUse.Domain.Dictionary,System.DateTime)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

The full error is this one

SQLite.FastColumnSetter.<>c__DisplayClass2_0`2[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.DateTime, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<CreateTypedSetterDelegate>b__0(Object o, sqlite3_stmt stmt, Int32 i)
SQLite.SQLiteCommand.<ExecuteDeferredQuery>d__12`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
System.Collections.Generic.List`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]..ctor(IEnumerable`1 )
System.Linq.Enumerable.ToList[Dictionary](IEnumerable`1 )
SQLite.SQLiteCommand.ExecuteQuery[Dictionary]()
SQLite.TableQuery`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ToList()
SQLite.AsyncTableQuery`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ToListAsync>b__11_0(SQLiteConnectionWithLock conn)
SQLite.AsyncTableQuery`1.<>c__DisplayClass2_0`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Collections.Generic.List`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ReadAsync>b__0()
System.Threading.Tasks.Task`1[[System.Collections.Generic.List`1[[LanguageInUse.Domain.Dictionary, LanguageInUse, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
System.Threading.Tasks.Task.<>c.<.cctor>b__281_0(Object obj)
System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object )
System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread , ExecutionContext , ContextCallback , Object )
System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& , Thread )
LanguageInUse.Persistence.LIUDatabase.GetDictionariesForSearchAsync(String username, String search)
LanguageInUse.ViewModels.DictionaryListViewModel.<Init>b__13_0(Object s, PopupOpenedEventArgs e)
System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
Foundation.NSAsyncSynchronizationContextDispatcher.Apply()
ObjCRuntime.Runtime.ThrowException(IntPtr )
UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr )
UIKit.UIApplication.Main(String[] , Type , Type )
LanguageInUse.Program.Main(String[] args)

I tried in debug and release on my real devices and the application is working. I saw on GitHub this quite similar bug but it is 2 years old. In this post, they recommend downgrading the SQLite version - 2 years ago - or building with these settings.

enter image description here

Also, I saw this other issue always on GitHub that is more recent. They said to use in Release for iOS this settings

<UseInterpreter>true</UseInterpreter>
<MtouchInterpreter>-all</MtouchInterpreter>

I don't want to send more updates to the Apple Store with a broken app. Do you face the same issue? How can I fix the problem?

@onurhazar
Copy link

@erossini any news after adding two properties? did you solve the issue? we are facing the same error.

@SergTomcat
Copy link

@erossini I'm still on 1.7.335 solely because of that issue. Does enabling interpreter really helps?

And what is current status of that problem?

@it11111111
Copy link

Also facing the same issue. Ive tried enabling the interpreter but it does not seem to help

@JawadJaber
Copy link

Same for me, version 1.7.335 also crash when published to the store.

@it11111111
Copy link

I don’t think this project is even maintained anymore. The funny thing is, Microsoft still lists it in their official documentation as a recommended tool.

@SinalyVector
Copy link

@it11111111 : Also facing the same issue. Ive tried enabling the interpreter but it does not seem to help

Try using the interpreter without <MtouchInterpreter>-all</MtouchInterpreter>. Instead, use only <UseInterpreter>true</UseInterpreter> as shown below:

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
    <UseInterpreter>true</UseInterpreter>
</PropertyGroup>

Add this to your .csproj file. It worked for me!

@it11111111
Copy link

@it11111111 : Also facing the same issue. Ive tried enabling the interpreter but it does not seem to help

Try using the interpreter without <MtouchInterpreter>-all</MtouchInterpreter>. Instead, use only <UseInterpreter>true</UseInterpreter> as shown below:

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0-ios'">
    <UseInterpreter>true</UseInterpreter>
</PropertyGroup>

Add this to your .csproj file. It worked for me!

Thank you! That's how I currently have it : ( After a few days of logging and trying different things, I found that my app crashes whenever I insert data into the sqlite table when the class inherits from an interface and the data types are different from strings. If I either remove the interface reference or ensure that the class inherits from an interface where all properties are strings, then it works as normal. However, this problem only happens in release mode.

If you have any other configuration ideas that I could add to the .csproj file, let me know. Ive tried different combinations but nothing has worked so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants