|
Post by apiotuch on Mar 12, 2020 21:23:15 GMT
We are having issues with iOS and mac, error: sqlite3.dylib: illegal multi-threaded access to database connection which crashes the app. And we understand that we have two option, multithreaded and serialized. With Serialized we can maintain one connection for multiple threads, but with multithreaded we have to set up a new connection for each thread. How can we set up each thread to have a different connection to the SQLite3 DB? Or how can we configure the SQLite3 DB to be serialized either from compile, startup or runtime through SimpleSQL or some other means? I am going by this solution but I do not know how I would configure this in Unity through SimpleSQL stackoverflow.com/questions/49198831/sqlite3-dylib-illegal-multi-threaded-access-to-database-connectionwww.sqlite.org/threadsafe.html
|
|
|
Post by echo17 on Mar 13, 2020 14:31:01 GMT
I'm sorry, but I have no experience with multi-threaded apps. It sounds like you are on the right track. If you need to make updates to the SimpleSQL codebase, take look at this FAQ: link
|
|
|
Post by apiotuch on Mar 16, 2020 18:53:16 GMT
Is there any way to reference or connect to the Sqlite3 DB directly through SimpleSQL in a separate objective c script so that I can shutdown, run config, and then initialize the DB again? I see that in c# there is a method SimpleSQL.SQLite3.Config which takes an argument of SQLite3.ConfigOption, with options MutliThread, SingleThread, and Serialized. However there are no methods Shutdown and Initialize available in the SimpleSQL.SQLite3 library. Simply invoking the Config method doesn't seem to do anything.
|
|
|
Post by chrismeteu on Sept 23, 2021 19:54:39 GMT
For anyone trying to use multi-threading I think this will work (not fully tested). Since you can only configure sqlite when it's in a shut down state, you'll need to add the entry points for Stopping and Starting yourself. **Perhaps in future releases it would be helpful to add more wrapper functions to sqlite for those of us that require more flexibility to how we use and access the database. Though then it may not be "Simple" anymore public class SQL_Setup_MultiThreading : MonoBehaviour { private const string dllPath = "sqlite3"; // "__internal"; public enum ConfigOption : int { SingleThread = 1, MultiThread = 2, Serialized = 3 } [DllImport(dllPath, EntryPoint = "sqlite3_initialize")] public static extern int Initialize(); [DllImport(dllPath, EntryPoint = "sqlite3_shutdown")] public static extern int Shutdown(); [DllImport(dllPath, EntryPoint = "sqlite3_config")] public static extern int Config(ConfigOption option); private void Start() { var s = Shutdown(); var r = Config(ConfigOption.Serialized); var i = Initialize(); Debug.Log($"{s} {r} {i}"); } }
|
|