Closed bruce-lumo closed 7 years ago
Can you please share a crash that's representative of the browser crashes you are seeing?
The two symptoms you note (browser crash, prompt for encryption key) sound like symptoms of attempting to open a Realm that has been corrupted. Have you attempted to verify that the Realm file that was stored to S3 matches the copy of the file that the device wrote out, and that the Realm file you've downloaded matches what is stored in S3?
Below is the crash report. I'll check the checksums, though I've never known S3 to corrupt such a large percentage of uploads/downloads so consistently.
Thanks!
The relevant frame from the backtrace is:
7 org.cocoapods.Realm 0x000000010aa56ea5 realm::Group::attach(unsigned long, bool) + 581
That corresponds to the REALM_ASSERT_3(top_size, ==, 9)
within Group::attach
. That definitely means that some of the data in the file is not valid.
If you can confirm that the files are making it unchanged from the originating device to the Mac you're opening them on, then that would indicate there's a bug either in how we're writing out the copy of the Realm, or in opening the copy. I think we'd likely need copies of an original Realm file and its copy to investigate. Feel free to email them to help@realm.io, referencing this issue number, once you've confirmed that the file's are making it unharmed from the device -> S3 -> your computer.
I wonder if this could be due to the issue that realm/realm-core#2480 fixes.
I can't be sure yet, I've made this change to work around a known corruption issue in the S3 SDK: https://github.com/aws/aws-sdk-ios/issues/415#issuecomment-285030692
I've also added checksums to the filenames so I can see when the corruption occurs. I'll report back after my qa team has had a chance to see if this is still happening.
So not sure this is related to your issues but I just spent the last 2 hours banging my head with the same problem. I realized that I changed the time on my device to a future time to test something related to local notifications.
Apparently that was causing the same behavior as the issue reported here. The 2 might be completely unrelated but for anyone stumbling across this issue, it might save you some time to check the date time settings on your device
@cmavromoustakos changing the time on your device shouldn't impact your ability to open Realm files. Could you please file a new issue with detailed steps to reproduce? It's almost certainly unrelated to what this issue is tracking, which is likely corrupt file transfers to/from S3.
Reporting back on this, its was definitely the S3 upload that was the problem here.
I'm happy to hear you managed to track this down!
Update: I was able to dramatically reduce the number of errors with uploaded realms by (1) the AWS tweak mentioned above and (2) copying the realm before uploading. In the same release as these fixes, I also started putting the md5 checksum in the filename. With these in place, I think I actually do still have a bug here.
The attached realm file matches the md5 generated on the iphone (in the filename), so I know the realm has made it to me intact. When I try to open it with realm browser I get the encryption key ask. This has happened twice for the same user. All other realms that I get with matching checksums open up just fine.
I was able to open that Realm file in Realm Browser locally. It doesn't appear to be corrupt.
Ah, there is an update to the realm browser. I can open it too after upgrading. Thanks!
Goals
In some user cases, I upload a copy of their realm to AWS S3. I make a copy with writeCopy(toFile: and then upload using the iOS framework that AWS supplies. I want to be able to download these realms to macOS and browse them with the realm browser available in the App Store.
Expected Results
I expect to be able to open these realms on macOS with the realm browser.
Actual Results
Some (about a third) of the uploaded realm files crash the browser or erroneously ask for an encryption key. They data is inaccessible.
Steps to Reproduce
Copy a realm on iOS, upload to S3, download and open with realm browser.
Code Sample
etc etc
Version of Realm and Tooling
Realm version: 2.4.2
Xcode version: 8.2
iOS/OSX version: iPhone 6s, iOS 10.0.2