Concurrency performance is the #1 issue we experience using SQLCipher for Android. We see many ANR reports, especially from older devices with slower I/O, that stem from what should be small database reads that occur on the main UI thread, that are blocked on SQLiteDatabase.mLock
because a background thread is performing another longer running database operation. SQLite, especially in WAL journal mode, should be able to perform these database operations concurrently, but the SQLiteDatabase
API has this internal lock, which Google’s SQLite API has improved the behavior of since the Jelly Bean platform update.
It’s admirable you’ve maintained backwards compatibility support for so many Android APIs. But even the 0.5% of devices that are running an older platform than Jelly Bean, could still run an app using SQLCipher with an updated SQLiteDatabase
implementation based on the latest Android platform code. Updating the API would only affect apps that might still be calling one of a few deprecated methods in SQLiteDatabase
. But there’s really no reason an app would need to be calling those methods, 7 years after they were deprecated. Every one of the deprecated methods either has a safer replacement, serves no purpose anymore, or specifically is used to deal with the poor locking behavior of the older API.
yieldIfContended()
This method was deprecated in API level 15. if the db is locked more than once (because of nested transactions) then the lock will not be yielded. Use yieldIfContendedSafely instead.
getSyncedTables()
This method was deprecated in API level 15. This method no longer serves any useful purpose and has been deprecated.
markTableSyncable(String table, String deletedTable)
This method was deprecated in API level 15. This method no longer serves any useful purpose and has been deprecated.
markTableSyncable(String table, String foreignKey, String updateTable)
This method was deprecated in API level 15. This method no longer serves any useful purpose and has been deprecated.
setLockingEnabled(boolean lockingEnabled)
This method was deprecated in API level 16. This method now does nothing. Do not use.
isDbLockedByOtherThreads()
This method was deprecated in API level 16. Always returns false. Do not use this method.
There is no longer the concept of a database lock, so this method always returns false.
With the Android platform SQLite code updates, the deprecated methods are still present, so updating the code doesn’t actually break old apps. The methods simply don’t do anything, as they no longer need to. It would work the same updating SQLCipher’s Android API and would bring much improved concurrency performance for all SQLCipher Android apps.
If I had the time to dedicate to it, I would be willing to assist in these updates, certainly with testing.