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

Realm makes JS FPS drop significantly when app stays offline for a long time #3882

Closed
salembaira opened this issue Aug 3, 2021 · 11 comments · Fixed by realm/realm-core#5030
Assignees

Comments

@salembaira
Copy link

salembaira commented Aug 3, 2021

I use Realm in production in several applications developed with react native. Multiple users complained that the app slows down significantly when they use it for several hours offline. The app is intended for offline-first use. Weirdly, when they go online, the app functions normally.

We use the latest realm-js version with react native, realm sync and react-native-navigation. I was able to reproduce the bug and realm is definitely the issue. I can give access to private repository if a contributor is interested.

@bmunkholm
Copy link
Contributor

Hi Baira!
Since you can reproduce this could you possibly try to debug it and reduce the problem to get to an understanding which Realm functionality is causing slowdown? Getting to a minimal reproducing sample would be great.
Thanks!

@salembaira
Copy link
Author

salembaira commented Aug 12, 2021

Hello Brian,

Thank you for your input! So I created a minimal reproducing example using npx react-native init which you can find at https://github.com/Baira/realm-bug. To reproduce the issue open the app while connected, try clicking on the various links and notice that everything works fine. Then disconnect and close the app. After sometime (seems random) while disconnected, open the app and you will notice that clicking on the links doesnt produce the "TouchableOpacity" effect smoothly. If you listen to the MessageQueue, you will notice that all UI events (touch, tap, etc.) are fired with a big delay.

After days of digging into this, it seems the problem happens whenever realm is opened in sync mode while offline. Something realm does blocks the bridge and thus prevents smooth UI interaction. I noticed that opening the realm in readonly mode resolves the issue but we need sync in our use case. You will find via this dropbox link two flamecharts of the app with realm opened in sync mode (thus producing the bug) and one without realm opened. https://www.dropbox.com/t/WD37tRBmP7nNLbOz

@salembaira
Copy link
Author

Hello Brian,

Thank you for your input! So I created a minimal reproducing example using npx react-native init which you can find at https://github.com/Baira/realm-bug. To reproduce the issue open the app while connected, try clicking on the various links and notice that everything works fine. Then disconnect and close the app. After sometime (seems random) while disconnected, open the app and you will notice that clicking on the links doesnt produce the "TouchableOpacity" effect smoothly. If you listen to the MessageQueue, you will notice that all UI events (touch, tap, etc.) are fired with a big delay.

After days of digging into this, it seems the problem happens whenever realm is opened in sync mode while offline. Something realm does blocks the bridge and thus prevents smooth UI interaction. I noticed that opening the realm in readonly mode resolves the issue but we need sync in our use case. You will find via this dropbox link two flamecharts of the app with realm opened in sync mode (thus producing the bug) and one without realm opened. https://www.dropbox.com/t/WD37tRBmP7nNLbOz

I forgot to mention that this happens on Android. I didn't test this on iOS.

@kneth
Copy link
Contributor

kneth commented Aug 16, 2021

@baira Thank you for the example and the description. We will run your example to see the behaviour.

@salembaira
Copy link
Author

@baira Thank you for the example and the description. We will run your example to see the behaviour.

@kneth Thank you very much! It's my pleasure to contribute to such a great piece of software.

@salembaira
Copy link
Author

@kneth @bmunkholm any progress on this ? Just asking, I know you must have many things to do.

@mednche
Copy link

mednche commented Oct 3, 2021

I'm encountering the same issue on iOS (Realm 10.8.0). When the app is opened in offline mode after having been in offline mode for some time (in our case, a whole night), the UI is extremely slow. Is there any fix for this yet?

@suleman-soren
Copy link

I am having the same issue if i leave the app offline for 30 minutes. If i click on a button then the click is registered after around 10 second.

@takameyer
Copy link
Contributor

We have a fix in realm-core. On the next release, this problem should be fixed!

@salembaira
Copy link
Author

We have a fix in realm-core. On the next release, this problem should be fixed!

Thanks a ton guys! can't wait for the next release!

@kneth
Copy link
Contributor

kneth commented Nov 18, 2021

The fix is included in version 10.10.1.

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

Successfully merging a pull request may close this issue.

7 participants