Open gl-lovekesh opened 2 years ago
Could you try the following (pseudo code) to open the store:
if Store.isOpen(directory) {
store = Store.attachTo(directory)
else {
store = Store(directory: directory)
}
If the app goes into background, it also may help to close the store.
Hi @greenrobot, Thanks for your response, We tried your solution as below.
init() {
do {
let directory = URL.storeURL()
if (try Store.isOpen(directory: directory.path)) == true {
self.store = try Store.attachTo(directory: directory.path)
} else {
self.store = try Store(directoryPath: directory.path)
}
} catch let error {
print("Unable to initialize persistence store: \(error)")
}
}
We are still getting crashes while going into the background. for reference: Shared app group directory path(/private/var/mobile/Containers/Shared/AppGroup/B2974F9C-4189-4597-8098-98A5171FC0FD/MobileAppDB)
Hi Guys Any update on this? I am also getting the same issue.
Could you try the following (pseudo-code) to open the store:
if Store.isOpen(directory) { store = Store.attachTo(directory) else { store = Store(directory: directory) }
If the app goes into the background, it also may help to close the store.
Any update on it? We got the same kind of crash on iOS 15 for realm for other applications. They fixed something. I tried to figure it out. I didn't get anything.
Any update?
Any update on this? This is the major blocker now.
@nisha-rana16 Is this still an issue with the latest version (1.9.2)? I'm not familiar with app extensions, but upon reading extensions like widgets seem to run in a different process? If the app goes to the background, this might probably cause the database to close? Then it can not longer be accessed from the extension process? So maybe handling that case might avoid crashes? (Though, it's generally a bad idea to access the same database files from different processes.)
As for a workaround: is it possible to just pass data to the extension from the app and the extension does not touch the database itself at all?
(https://stackoverflow.com/posts/71414769/timeline)
I was trying to share the Objectbox created database between the app and its extension. I used the below code to share the database between the app and its extension.
The app is working fine when the app is running in foreground. When the app goes to the background then the app is crashing. When I remove the above code and used the below code
The app does not crash and started working fine without Database sharing.
Note: If we ignore this crash, I was able to use the database from the app and its extension. We can not ignore it because it happens every-time.
Basic Infor Object Box : 1.5.0 iOS: iOS 15 and above Device: Any iPhone not simulator
Step to Reproduce
Log