Crash when starting realm

Hello,

Well, we’ve screwed up and are in a bad spot, and I am looking for advice.

iOS, Realm 3.17.1. For reasons to long to detail, we had a significant number of users crash during the migration block execution. Nothing was happening in that particular block (we were logging that the user had migration to that version of the schema).

After fixing that, we’ve found that our app crashes when attempting to instantiate Realm. Realm(configuration) throws an exception. We’re waiting for analytics to tell us what the exception is.

Is there a way to get out users out of this state? My current plan is to update the schema and deleteRealmIfMigrationNeeded, but I am curious if that would be expected to work, or if there is something else that might be a better idea.

Thank you,
Justin

Yeah if you just want to solve the problem immediately then wiping the local realm file should fix any lingering issues. You can do that as you mentioned with the deleteRealmIfMigration needed flag, and then trigger a dummy migration. Or you could use the deleteRealm API or manually delete it using NSFileManager or similar before opening the realm.

Hopefully the app crash is related to some sort of corruption of the realm file, otherwise, you could be wiping state without fixing the problem. The exception should tell us that

Thank you. I’ll post the exception if we manage to get it. Oddly, we are utterly unable to reproduce this in house, and it doesn’t appear to be a 100% thing for our users. Due to where we start up Realm, I am concerned about our ability to get the event to crashlytics.

For what little it is worth, the last thing in the stack trace is

$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtFTf4xxnnn_n + 440 (AssertCommon.swift:132)