-
Notifications
You must be signed in to change notification settings - Fork 199
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
DataStore is not syncing on watchOS #3220
Comments
Thanks for opening this issue @depthzadmin and including a repro project! |
I tested with Amplify 2.18.1 and the watch still does not sync. Here is the startup details: objc[730]: Class _TtC6SQLite6Backup is implemented in both /System/Library/PrivateFrameworks/LinkServices.framework/LinkServices (0x792ce2fc) and /private/var/containers/Bundle/Application/7CEB5CCA-3243-4652-9EE7-378E1677C276/AmpWatch Watch App.app/AmpWatch Watch App (0x6c80e94). One of the two will be used. Which one is undefined. |
Thanks for testing with the most recent version and for your patience while we continue to investigate. |
@depthzadmin can you please paste the contents of your |
Does the watch app have network connectivity? In the latest logs, do you still see " This log is coming from AppSyncRealTimeClient. DataStore uses APIPlugin, which uses AppSyncRealTimeClient, which uses https://developer.apple.com/documentation/network/nwpathmonitor . I suspect because it detected that no network is available, so DataStore is waiting for the subscribe callback to fire and the sync process is stalled because of it |
The watch app does have network connectivity. When using the reproduction Xcode project, you can verify connectivity by tapping on the button "URL" which makes an http call, or tap the button "Device" to make a message send to the associated phone app. |
Thanks @depthzadmin. I'm not able to reproduce what you're experiencing with the project you provided. Could it be that you didn't enable conflict detection in Amplify CLI while adding API (GraphQL)? If that's not the issue, please enable verbose logging and paste the logs here to help us identify the difference. Amplify.Logging.logLevel = .verbose Thanks! |
Here is the verbose log for both the watch and the phone. WATCH: PHONE: |
Same issue here with Amplify 2.19.0, but this occurs only on real device (on simulator it's fine). |
Thanks for the logs @depthzadmin and thanks for letting us know that this is also affecting you @gbitaudeau We'll follow up here with any updates. |
Sadly we can't put our first watch application which use Amplify in production due to this issue. |
Hi @gbitaudeau @depthzadmin, could you try out the |
Hi @lawmicha, I just tested, but this doesn't change anything : the synchronization didn't start. |
Thanks for the logs @gbitaudeau, can you clarify that it is still working on the watchOS simulator but doesn't on the physical device? The end of the logs show
perhaps it is stuck in the websocket connect steps? Could you provide us with a reacted schema that you are using and the expected auth set up? |
Hi @lawmicha , I created a short project from scratch using the default amplify schema and I can confirm that it is still working on the watchOS simulator but doesn't on the physical device. I only activated
|
Hi @thisisabhash @lawmicha do you have enough information? Did you reproduce the problem on your side? |
Hey @gbitaudeau, do you have any logs from the physical device run? |
Hi @lawmicha , I pushed further investigations and here what I observed:
When I ran the application, there were several problems because date in milliseconds use If I resume:
Hope all this help. On our side, the situation is quite critical: we though Datastore work on watch and we changed all our core stack to use Datastore but we can't put our application in production because all this don't work on watch. Do you think you will be able to fix Datastore in a reasonable time (even without web socket)? We don't need real time on watch and if we must do polling (using stop/start on Datastore), this could be ok for our use case. In our position, we also consider to remove Amplify from watch depending on your answers. |
Hi @gbitaudeau, we should be able to do a client side check for watchOS to avoid establishing the subscriptions. We're a bit confused why With the two changes, real-time updates as you mentioned will not be received by the app on watchOS, however data will still be sync-ed to the cloud through the GraphQL mutations since they are HTTP POST requests. To do data polling, DataStore.stop() will stop the sync engine, and DataStore.start() will kick off the syncQuery API calls to pull the latest data. Some additional context about |
Hi @depthzadmin and @gbitaudeau, please try out the |
Making progress. My findings:
|
Hi @depthzadmin, thanks for your observations. They're very helpful as we work through getting DataStore to run on watchOS without subscriptions. One of the limitations you noticed is that the phone data is not synced to the watch unless the watch app is restarted. The reason for this is due to the lack of low-level networking support by watchOS. Normally, DataStore uses the websocket subscriptions to reconcile the data immediately. Since subscriptions are not going to work, data becomes stale on the watch until the next sync. A sync occurs when
Do you have more details such as sequence of actions you took, code snippets, or logs around the issue with deletion of data? on the watch and phone? Deletion of data not working on the phone is unexpected. We'll have to investigate further DataStore on watchOS functionality such as create, updates, and deletes. |
There is nothing in the logs about the delete. In the code the delete appears to be working, but when doing a query the data is not deleted. |
How are you querying the data back? |
My test app has a separate button for delete and query. I first tap on delete, wait a bit, then tap on query. The data is still in the local store even after restarting the device. Also, data deleted from the Amplify Web Console does not get synced to the devices. |
Hi @lawmicha and thanks for this new version. It's promising: the sync engine well start this time and I can see that all the Sync request are well sent on network.
You can find here device logs and Charles proxy session where I made a mutation just after the sync was finished. Two others observations :
|
Thanks for the investigation, I'm taking a look into this and the changes related to using Int64 is what's causing the problems related to mutations and deletion. What's happening here is that the first save causes a create mutation to be sent out, but the metadata about the model isn't being reconciled successfully to the local store, so subsequent deletions fail when there's no version metadata. I'm also working on proposing a client side configuration option for DataStore specifically to disable the real time functionality, for use cases such as running on watchOS, which will remove the attempt to establish the subscriptions completely, reducing the time for the DataStore to finish the sync process. |
Hey @depthzadmin, @gbitaudeau, please try out Please keep in mind that I'm working on reviewing this change with the team, so a disclaimer it may change. try Amplify.add(plugin: AWSDataStorePlugin(
modelRegistration: AmplifyModels(),
configuration: .custom(disableRealTimeUpdates: { true }))) |
Naming updated to try Amplify.add(plugin: AWSDataStorePlugin(
modelRegistration: AmplifyModels(),
configuration: .custom(disableSubscriptions: { true }))) |
Hi @lawmicha and thanks for this new version again. I didn't finish all my tests, but for now :
I'll continue testing it today, and if I find anything else I'll post it here. Thanks for the fixes. |
Hi @lawmicha, I continued testing and didn't find any issues. Is there still work on your side to merge it? We are waiting it to put our app on the App Store 😉 |
Hi @gbitaudeau, thanks for confirming on your side things are working as expected. I just rebased |
Hi @gbitaudeau, we have a scheduled release early next week that incorporates this patch. I'll let you know once it's completed. |
Hi @lawmicha @5d , I tried the updated branch and everything looks good. The only problem I get is with |
Hey @gbitaudeau, thanks for the heads up, no my changes haven't touched that plugin. Can you please open another issue with any additional details to track the issue related to |
The DataStore fix has been released in https://github.com/aws-amplify/amplify-swift/releases/tag/2.23.0 |
resolving this ticket as fix has been released in the latest version |
Describe the bug
I created a small test Xcode project that uses the same code on the phone and the watch. Using DataStore on the phone works for syncing contents of a model (including create, delete, and query). Running this same code on a watch does not sync the data created by the phone.
Attached is the Xcode project.
AmpWatch.zip
Steps To Reproduce
Expected behavior
Data added to DataStore on the phone should be synced to the watch
(see the log output below for the output from the Xcode console)
Amplify Framework Version
2.17.1
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.8
CLI version
12.2.5
Xcode version
14.3.1 (14E300b)
Relevant log output
Is this a regression?
No
Regression additional context
No response
Platforms
watchOS
OS Version
watchOS 9.6.1
Device
Apple Watch Series 4
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: