-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS crash due to default.realm.lock': open() failed: Operation not permitted Path #7874
Comments
Hi @haozhutw it seems like we are not able to access the file and because Have you seen any increase of crashes in any particular iOS version?. One change we can make it is to always set up the file protection for the folder.
Do it before opening the realm using
making sure it is executed every time |
@dianaafanador3 Thank you for the advice! I'll try it out. |
@dianaafanador3 This crash happens on iOS 12 and above versions, most of them happen on iOS 15 because most of the users are using the latest iOS system. I have updated my code logic, hope this issue can be fixed after my app goes live next time. |
@haozhutw I'll leave this parked for a few months, let us know if after the update this keeps happening. |
Hi @dianaafanador3, I found another crash after publishing a new version of my app. Here is the crash log
I did change the file protection to |
I set file protection to |
Hi @haozhutw you should just set Just a couple of questions:
|
Thanks for your reply. I don't have App Groups enabled and no app extension. This crash is reported by Firebase and from the report it happens on foreground, here is the screenshot. |
@haozhutw can you update to the latest version of Realm and see if that helps. |
Just in case it's useful for anyone else with this issue, we tracked it down in our app to the MFi App Launch feature, where if the user powered on their iOS device but didn't unlock it, when the MFi Bluetooth device was powered on and the app launched (underneath the locked screen) any access to files in the app's documents folder would fail with the same error seen in this report. The Crashlytics issue in our case also showed the app as not being in the background, but this isn't totally true - it's underneath the lock screen, not in the background ;) So this could occur if the app makes use of any feature that could launch the app before the user has ever unlocked the device (geofencing maybe?) Our initial workaround is checking |
Still encounter this issue on the production environment
|
@haozhutw There is nothing that points to a bug in Realm as far as we can tell. This appears to be a problem in your application that happens to occur when you open a Realm. |
@bmunkholm one use case was provided by @benlacey , in our case, this crash happens when the app receives a push notification after the device was rebooted but not yet unlocked. Realm is stored in a shared app group's directory and is accessed by a push notification service extension. As a fallback, even the attempt to boot an empty in-memory realm fails as well, because it still tries to write the |
@nalexn did you try change the folder protection permissions in your App Group directory? |
@leemaguire I did, though I don't set it to |
@nalexn thanks for the details, I'll bring this topic back up for discussion with the team to see if anything can be done. |
I'm closing this issue as I have submitted a feature request for #7874 (comment) in Realm Core. |
How frequently does the bug occur?
Sometimes
Description
Expected
The crash shouldn't happen.
Actual result
The crash happens during app startup process. We did a database migration in function
application:didFinishLaunchingWithOptions
inAppDelegate.m
Stacktrace & log output
Can you reproduce the bug?
Not yet
Reproduction Steps
This crash is found on the Firebase console, I can't reproduce it. According to the Firebase, it happens more than 600 times and affects more than 300 users. I tried solutions in other issues below:
#3308 (comment)
#5938 (comment)
#1260 (comment)
#1874 (comment)
#1571 (comment)
And I even looked up the docs https://docs.mongodb.com/realm-legacy/docs/swift/latest/index.html#using-realm-with-background-app-refresh, but after updating my code I still see this crash happens on the production environment.
Here are my code about migration
I created a sub directory in document folder, move the default.realm file and default.realm.lock file to this sub directory and set its attribution to NSFileProtectionNone, but still seeing this crash on the production environment.
Version
Realm 10.7.2
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
iOS 14
Build environment
Xcode version: 13.1
Dependency manager and version: CocoaPods 1.11.3
The text was updated successfully, but these errors were encountered: