Open pixelmatrix opened 1 week ago
Hi @pixelmatrix,
After some research, it appears to be due to keeping the SQLite database file located in the App Group's container. It looks like other people have fixed these crashes by using the database in WAL mode.
Can you share more evidence that points to the change in journaling mode being the solution to the crash. We're not against making this, or other pragmas, available but something conclusive that demonstrates this change resolves the issue will be helpful. Apollo iOS can be forked so making the change on your own fork while proving out the theory should be possible.
@calvincestari yes, definitely. I've forked the repo and I'm running it in WAL mode in a recent TestFlight release.
So far the crashes have stopped, but it hasn't been long. I will continue to monitor for a week or so to see if we get any further crashes. Would that be enough evidence? I can also share some of the trace which points to the app being killed while SQLite is active.
Yes, that sounds good. Monitor it, gather what you need to and then let's evaluate once it's had some time to prove itself.
Use case
I've been investigating a regular background crash in our app. After some research, it appears to be due to keeping the SQLite database file located in the App Group's container. It looks like other people have fixed these crashes by using the database in WAL mode. This is possibly by executing a PRAGMA statement:
Describe the solution you'd like
Would you be open to exposing this as an option in some form?
A few API ideas:
setJournalMode(_ mode: JournalMode) throws
onSQLiteDatabase
protocolexecute(_ sql: String) throws
onSQLiteDatabase
, which would allow direct access to execute any PRAGMA commanduseWAL
as an optional init parameter ofSQLiteNormalizedCache
Alternatively, I could implement my own
SQLiteDatabase
, but that is currently not possible becauseDatabaseRow
does not have a public initializer.