iOS15.3 app进入后台30秒左右,被系统干掉了
错误信息: 2022-01-29 16:51:04.249682+0800 [application<com.hillhouse.signal>:7921] Terminating with context: <RBSTerminateContext| domain:15 code:0xDEAD10CC explanation:[application<com.hillhouse.signal>:7921] was suspended with locked system files: /var/mobile/Containers/Shared/AppGroup/9A32AC07-64CA-43E9-8A9F-7D562418E213/Search/MessageSearch.db not in allowed directories: /var/mobile/Containers/Data/Application/40FA60D8-2175-4DAD-9191-0E35C19C51DA /var/mobile/Containers/Data/Application/40FA60D8-2175-4DAD-9191-0E35C19C51DA/tmp reportType:CrashLog maxTerminationResistance:Absolute>
类似错误在realm上也有,不过人家修复了: https://github.com/realm/realm-swift/issues/6671 https://github.com/realm/realm-swift/issues/6861
我在SQLCipher的issues也看到了类似的问题: https://github.com/sqlcipher/sqlcipher/issues/255
你没这个问题有没有修复啊
PRAGMA cipher_plaintext_header_size Allocates a portion of the database header which will not be encrypted to allow identification as an SQLite database. The size must be greater than 0, a multiple of the cipher block size, and less than the usable size of the first database page. An example of setting the plain text header size is below:
PRAGMA cipher_plaintext_header_size = 32;
This PRAGMA is primarily intended for use on iOS when a WAL mode database will be stored in a shared container. In this special case iOS actually examines a database file to determine whether it is an SQLite database in WAL mode. If it is, then iOS extends special privileges, allowing the application process to maintain a file lock on the main database while it is in the background. However, if iOS can’t determine the file type from the header because it contains random data like a SQLCipher database, then iOS will kill the application process when it attempts to background with a file lock.
In order to work around this issue, an iOS developer may provide instruction to SQLCipher to leave a portion of the database header unencrypted (plaintext). In this case SQLCipher will leave the specified number of bytes in the original SQLite file format and will only begin encrypting data after that. The recommended offset is currently 32 - this is small enough to ensure that sensitive information like schema and data are not exposed, but will ensure that the important SQLite header segments are readable by iOS, i.e. the magic “SQLite Format 3\0” and the database read/write version numbers indicating a database is operating in WAL journal mode (offsets bytes 0 - 19). This will allow iOS to identify the file and will permit an application to background correctly without being killed.
这个调整我在 Fork 里加上了,你可以帮忙试试: https://github.com/cntrump/wcdb/commit/51a9071fcfd44cf98b07eaf6d7592755e24c9225
https://github.com/cntrump/wcdb
我也遇到这个问题了,哪位大佬能提供一下解决方式?
我也遇到这个问题了,哪位大佬能提供一下解决方式?
setCipherKey 的时候设置 shared = true 试试?
shared
我这边试了一下,setCipherKey 的时候设置 shared = true ,还是没能解决
Here is the reason for that crash: https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_plaintext_header_size
You can config cipher_plaintext_header_size with StatementPragma through Database.setConfig(named:with:orderBy:).