Skip to content
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

Update from Realm 7.0.8 to 10.4.0 is very slow #7426

Closed
jpmcosta opened this issue Apr 15, 2021 · 6 comments
Closed

Update from Realm 7.0.8 to 10.4.0 is very slow #7426

jpmcosta opened this issue Apr 15, 2021 · 6 comments

Comments

@jpmcosta
Copy link

jpmcosta commented Apr 15, 2021

Goal

I'm trying to update my application's local and unencrypted database from version 7.0.8 to version 10.4.0.

Actual Results

The update from version 7.0.8 to version 10.4.0 seems to be very slow and I still wasn't able to complete the operation once in my testing device. While it might have completed if I left it long enough time in the foreground (I have waited around 10 minutes), I don't think I can ask users to have the application in the foreground for several minutes waiting for it complete the update. Plus, I believe it might be exceeding the maximum allowed time in the background.

I also have noticed that when there's a call to Realm.getInstanceAsync() in the UI thread while Realm is already trying to update the database (from a Realm.getInstance() call in a background thread or a different call to Realm.getInstanceAsync()), that call will block the UI thread, causing an ANR. I have worked around that issue, but I thought I should mention it.

Steps & Code to Reproduce

I have created a simplified Android project to reproduce the issue:
https://github.com/jpmcosta/RealmTestProject/tree/e53e945d35ea6faefaf53e26eb4c34c486c4369b

The project includes a default.realm file that was generated in Realm 7.0.8 and should be used to test the update.

With that file, the update takes:

  • 87 seconds in the emulator
  • 217 seconds in my testing device

While it does complete there are a few differences to my original database:

  • the file schema has 5 classes, my database has 20 classes
  • the file is 28.8MB, my database file is 170MB
  • the file has considerably less fields and indexed fields

Version of Realm and tooling

Realm version(s): 7.0.8, 10.4.0

Realm Sync feature enabled: No

Which Android version and device(s): API 29 (device and emulator)

Thank you for taking a look into this.

jpmcosta added a commit to jpmcosta/RealmTestProject that referenced this issue Apr 15, 2021
@jpmcosta
Copy link
Author

I was indeed able to update my database. It took around 663 seconds.

@clementetb
Copy link
Collaborator

@jpmcosta thanks for reporting the issue and providing an example project.

The reason it takes time to open is that there is a file version upgrade between those versions and Realm has to migrate it to the new format. We have escalated the issue to the core team to know why it takes this great amount of time to complete.

@jedelbo
Copy link

jedelbo commented May 20, 2021

We recognize that this is indeed slow. We are working on a solution to fix this.

@finnschiermer
Copy link

Expected fix released in Core v11.0.0-beta.6

@bmunkholm
Copy link
Contributor

This has been released now and will be released shortly in SDKs.

@cmelchior
Copy link
Contributor

10.6.0 was released with a fix for this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants