-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Possible corrupt realm database. Crashes on start for some users after RealmSwift 2.0.3 #4302
Comments
Thanks for reporting this @fishfisher. Could you please share the Crashlytics logs included in your crash reports? Realm folks: Also tracking this in Helpscout #4273 also has an assertion failure in |
Thanks for reporting back. Here is the full stack trace of one of the crashes:
|
Allrighty, after a lot of head scratching I have progressed a bit: I have narrowed down that the crash is happening in the setup of the realm config in 'didFinishLaunchingWithOptions'. At let _ = try! Realm().. I use the following code to set up the default realm. I'm basically checking that the standard realm exists and if it does I move it to a shared location so it can be accessible from my extension.
This is how I was able to identify where the crash happened: I now have that realm-file and it crashes the Realm browser when I try to open it. Regards, |
Yes! Could you please email the file to [email protected] referencing this issue? We'll take a closer look at it. |
Thank you for your quick reply! Mail sent! |
@fishfisher A perhaps dumb question: what is the Today Extension doing at the time the error occurs? |
@finnschiermer No, not at all. But, unforunately, I don't know much about the status of the Today Extension as the crash occurs. I have done a lot of testing with the extension together with launching the app, but I have not been able to reproduce. I have suspecing a conflict with the extension. |
Just some further thoughts around my issue.. As you can see in my migration class I look for pathForSharedGroup. If it is not found (which I though could not be possible), I do not migrate and a crash will happen when the un-migrated realm is accessed. Can this be a cause for the issue? If so, does anybody know how FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.erik.myapp") can fail for some users? |
^ @jpsim |
This sounds like the file system operations you're performing might be prone to a race condition, if one process (e.g. main app) creates the Realm file after another process (e.g. Today extension) has checked to see if the file exists, but before the Realm can be moved by the second process (Today extension), then the Realm will be accessed while file system operations are being performed on it. Are you sure you've ruled this scenario out? It would likely require some sort of interprocess mutex to ensure the race condition doesn't happen. |
Thanks for getting back to me. I haven't ruled this out. I will try to disable the realm in my today extension (as its usage is not as critical there as in the main app) so the file system operations are only executed in the main app. If the crash disappears we've found the reason. |
"Can this be a cause for the issue? If so, does anybody know how FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.erik.myapp") can fail for some users?" |
We have found out that there might be problems if you access the same .realm file from two different apps/processes (multiple threads within the same app/process is fine though). The apps/processes need to be running different versions for the error to occur: One needs to be Realm Cocoa 2.0.2 or older, and the other needs to be Realm Cocoa 2.0.3 or newer. Is this the case? |
@rrrlasse Thanks for getting back to me. Both the main app and the extension targets the same pod in cocoapods, so I don't think they can be on different versions of Realm. However, this crash did start after going from RealmSwift 2.0.2 to 2.0.3. |
@rrrlasse multiple processes on iOS/tvOS/watchOS accessing the same file will always be using the exact same version of Realm due to how those apps are allowed to be distributed. All bets are off for macOS and Android though. @fishfisher I really still think the issue is the file system operations you're performing being racy. It's quite possible that changes between Realm Swift 2.0.2 and 2.0.3 made this race more likely to occur, but that the race was always there in the first place. |
@fishfisher have you made any progress on this? Thanks! |
@jpsim Thanks for checking back. I'll be releasing a new version soon with Realm 2.1.1 and a quick fix for the possible race condition during initial realm access. TestFlight builds are looking good! |
Great. I'll be closing this until we hear back from you then. |
After updating to Realm 2.0.3 I am seeing a lot of crash reports that I do not understand much of, and users are reporting that they are not able to open the app.
I don’t even know where to start when it comes to troubleshooting this issue. Please let me know what you need from me for troubleshooting!
The app uses a Today Extension with a shared realm.
Goals
Help with troubleshooting to identify the source of the issue
Expected Results
App not to crash
Actual Results
Crash on start.
Most of the crashes looks the same. I will add the partial stacktrace for some of them.
Steps to Reproduce
I do not know the steps to reproduce as only about 0.01 % of the users are experiencing these crashes.
Version of Realm and Tooling
Realm version: 2.0.3
Xcode version: XCode 8
iOS/OSX version: iOS 9.3.5 - 10.1.1
Dependency manager + version: CocoaPods
The text was updated successfully, but these errors were encountered: