-
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
open() failed: Operation not permitted #3217
Comments
Seems to be duplicated as #1874, but the solution doesn't seems to be the best, something better to do? |
@dchohfi could you please share the exception message? Initializing a Realm can fail for a number of reasons. See our docs on Error Handling for details. |
Hey @jpsim thank you for the fast reply, it seems to be related to iOS file protection defined by the application. Now I'm removing the file protection on all realm files as you described here: Just curious to know when I should be calling this? |
The file protection attributes can only be set on existing files, so you need to do that after initially opening the Realm file. |
@jpsim cool, makes sense. Do you think it's appropriate to have a single method on realm configuration to do that for us? Also doing the lazy creation logic. PR's are accepted? Or this is like that by design? |
I think it's worth improving this use case, and others like it. We could expose a Another option would be to add a getter to I'm curious to hear what @tgoyne and @bdash would think of that. |
@jpsim cool, just curious to know how the auxiliary files are created and if they are deleted and created again. If they are, do I need to change the |
The file protection attributes have to be set on the containing directory and not the individual files, as some of the files are created lazily and thus otherwise can't be created if the device is already locked when the first commit is made. |
Realm needs to be able to create files in the same directory as the Realm file while the device is locked if you want to be able to use the Realm file while the device is locked. Creating files while the device is locked requires that the containing directory have file protection disabled. |
@tgoyne so we don't actually need to remove file protections on auxiliary file paths if I have removed on the containing directory? |
Yes, files inherit their default file protection settings from the containing directory. |
From the sound of it, the immediate fix for this would be to simply set the file attributes property of the parent directory. I might check our docs to make sure this is highlighted. I like the idea of adding a file attributes property to @dchohfi Did you end up getting it working in the end? |
Hey @TimOliver, honestly saying? I don't know if it's fixed or not, the crash was related to file protection that was activated on the app. But how we discovered that was tricky. We found a crash on crashlytics during beta release and had to identify who was the person who had that, he said that never faced any crash during the beta and we realised that was something related to the notification that awakes the app in background. Now we added the flags and released a new version following what we spoke in this thread. And wait a bit to see if fixed or not, as replicate is quite difficult. That is why I think some attribute on |
Also, as you guys recommend to remove file protection from realm files, could be this the default behaviour and let the user change if needed? |
I don't think that this is actually possible. If the directory is protected, it should be encrypted when the device is locked. If
Setting the default file attributes for newly created files won't be enough though. I think we would need to check the parent directory instead. One problem here might be that there could be likely any arbitrary other user files adjacent to the default Realm path, which should be better protected in some cases. So just removing the protection by default might not be the best solution. (Perhaps we should think about scoping the default Realm path by another directory element, so that it is easier to workaround this case?) |
@mrackwitz great points, the |
I think, we can close this in favor of the issues created by @jpsim. |
Using Realm (0.98.1)
Facing following crash, no specific device, happening on all iPhones. iOS 8+.
After calling
+[RLMRealm defaultRealm]
got the stacktrace:Realm configuration initialized on app creation, before everything.
All crashes seems to be happening after a push notification tries to awake the app.
Any idea on why this is happening?
The text was updated successfully, but these errors were encountered: