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

Initial DataStore Sync Slow for Android Devices #4686

Closed
jackcho0301 opened this issue Apr 9, 2024 · 4 comments
Closed

Initial DataStore Sync Slow for Android Devices #4686

jackcho0301 opened this issue Apr 9, 2024 · 4 comments
Assignees
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category pending-release Issues that have been addressed in main but have not been released

Comments

@jackcho0301
Copy link

Hello,

My development team is having trouble with initial syncing using DataStore, specifically on Android.

Description of the issue:

After a fresh install of the app, and once a user signs in using Amplify's Authenticator widget, a user should be able to have access to models fetched from DataStore. We use Amplify.DataStore.observeQuery() to fetch this specific model.

On iOS devices, the initial sync for DataStore seems to happen fast and Amplify.DataStore.observeQuery() fetches snapshots instantly. But it takes a long time for Android devices to sync data for the first time, resulting in observeQuery() fetching empty snapshots a multiple times, and finally fetching a complete snapshot.

I noticed that observeQuery() on Android will fetch the complete snapshot once the following logs are shown on the terminal:

I/amplify:aws-datastore(12906): Successfully sync'd down model state from cloud.
I/amplify:aws-datastore(12906): Starting processing subscription data buffer.
I/amplify:aws-datastore(12906): Started the orchestrator in API sync mode.
I/amplify:aws-datastore(12906): Started processing the mutation outbox. Pending mutations will be published to the cloud.

So my team reached a conclusion that DataStore takes long time for syncing the models. And we need your guidance to help resolve this issue. This has been an ongoing issue for almost a year, and we really hope to understand why initial DataStore sync is slow for Android devices. We can provide an obfuscated version of our code and/or GraphQL schema if it would help.

Also, are there best practices that would help data models to be synced faster? Our team was considering reducing the number of models being synced by using DataStoreSyncExpression to selectively sync certain models only. And we could choose to not sync some models that do not benefit from DataStore's local-first behavior in our use case. If this approach does not sound reasonable, please let us know what the proper best practices would be.

Misc information:

Flutter Version: 3.10.5
amplify_flutter Version: 1.4.1
amplify_datastore Version: 1.4.2
compileSdkVersion on android/app/build.gradle: 33

Thank you for your time!

@Equartey
Copy link
Contributor

Equartey commented Apr 9, 2024

Hi @jackcho0301, This is something our team is aware of and currently working to address. We'll update your more concretely when a fix is released.

In the meantime, can you confirm the Android version you're observing the issue on? And the amount of models your project has?

@Equartey Equartey added bug Something is not working; the issue has reproducible steps and has been reproduced pending-release Issues that have been addressed in main but have not been released datastore Issues related to the DataStore Category labels Apr 9, 2024
@jackcho0301
Copy link
Author

Hello @Equartey , thank you for the response. We are observing this issue on Android 14, both physical and virtual devices. And we have 12 models for our project.

@amitchaudhary140
Copy link

Yes I am also facing same issue on Android.

@NikaHsn
Copy link
Contributor

NikaHsn commented Apr 17, 2024

Thank you for your patience. The issue has been fixed in version 1.8.0. and I'm closing it. However, if you encounter any issues after updating to version 1.8.0, please don't hesitate to reopen it.

@NikaHsn NikaHsn closed this as completed Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category pending-release Issues that have been addressed in main but have not been released
Projects
None yet
Development

No branches or pull requests

5 participants