-
Notifications
You must be signed in to change notification settings - Fork 198
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
can not receive update Subscription event on 2.29.2 SDK version #3632
Comments
Hi @smediomike, can you clarify with which API calls you making? In step 3. upload such picture to s3 storage, how do you upload the S3 picture, through Amplify.Storage.upload? And where/how is the mutation sent for the client to receive the subscription event? |
Hi @lawmicha
let s3Dict = [ "roomId" : room,
"s3_key_filename" : fileName as Any,
"s3_key" : content.s3_data as Any] as [String : Any]
jsonDict = [ "variables" : s3Dict,
"query" : "mutation Mark_delete_cloud_backup_ImageVideo($s3_key: String!) {\n mark_delete_cloud_backup_ImageVideo(s3_key: $s3_key) {\n userId\n album\n dateAdded\n dateBackup\n dateModified\n dateTaken\n deviceId\n duration\n hash\n height\n id\n isdeleted\n localPath\n mimeType\n orientation\n roomId\n s3Data\n size\n title\n tn1S3Data\n tn2S3Data\n type\n width\n createdAt\n updatedAt\n _version\n _deleted\n _lastChangedAt\n }\n}\n"
] as [String : Any]
var jsonData : Data? = nil;
do {
jsonData = try JSONSerialization.data(withJSONObject: jsonDict as Any, options: .prettyPrinted)
}catch {
}
let request = RESTRequest(apiName:"dataStoreApi",path: nil, body: jsonData)
let data = try await Amplify.API.post(request: request)
let str = String(decoding: data, as: UTF8.self)
print("mark delete Success: \(str)")
Note: this issue only happen iOS application go to background and then back to foreground. if application always keep in foreground, this issue will not happen. I will check more whether we need to step #1 again if application go to background before. thanks for your help! |
Hi @lawmicha add more information, I cancel old Subscription and add new Subscription after go to foreground, this issue still happen. BTW, once happen this issue, this "update" record will not be sync to local datastore till to re-start application. |
Hi @lawmicha |
Hi @smediomike, We've recently addressed an issue that was causing network-related problems in the latest version 2.33.3. Thanks! |
Hi @ruisebas We have also being struggling with this same issue with the latest version 2.34.2 and with 2.33.3. |
Hi @umamario @smediomike |
#3734 has been released in https://github.com/aws-amplify/amplify-swift/releases/tag/2.35.1 Please let us know if you are still experiencing any issues from 2.35.1 and newer |
I used 2.35.1 version to re-test, such issue still happen. and client side do not show any AWS SDK log at that time. |
Same problem with 2.35.3.
|
Hi @smediomike @tobias-feldmann , In the described test scenario, how long does the app remain in background mode before becoming active again? |
Hi @5d When the app is back in the foreground, I get the error from above. |
Hi @tobias-feldmann , Thanks for the information. By the way, are you testing on a real device? What is the internet environment like? Is it connected to both Wi-Fi and cellular networks? |
You are welcome @5d |
Hi @tobias-feldmann , I was not able to replicate the |
@5d Looks like the error is coming from the AppSyncRealTimeClient:
Several selects are made via the DataStore beforehand, then the errors occur.
|
Hi @tobias-feldmann , Thank you for the information. I tried to reproduce the issue using an iOS 15.6 simulator but had no success. We currently do not have a test device running iOS 15. We will contact other teams to see if they have one available. Regarding the |
Hi @5d |
@5d Do you know which version I could go back to where the problem does not exist? Because this function is critical for our app and I need to provide a fix. |
I have now tested different amplify versions with 2.35.0, 2.33.4, 2.33.2 it does not work. But it works with 2.28.0. Is probably related to the changes in 2.29.1 |
@tobias-feldmann Thanks for providing all that valuable information. It could be probably 2.29.1. Our team will investigate and provide an update soon. |
Hi @tobias-feldmann , Thanks for the information. I was able to reproduce the issue with Xcode disconnected. I'm noticing that when the app transitions to the background, the WebSocket connection encounters a system network abort error. This error is originating from the iOS system through URLSession delegate methods, and we propagate these errors downstream. However, these errors do not terminate the data stream on the Amplify observe API or the subscription API. I can see the reconnection attempts in the logs, and data updates are received from other devices continue afterward. Are you expecting not to receive the error messages? Or is the issue that data is not received once the app returns to the foreground? Here are my logs:CloudWatch Logs Insights
|
Hi @5d |
Hi @tobias-feldmann , The version 2.29.1 contains switching from the third-party dependency library Starscream to Apple's native WebSocket solution, URLSessionWebSocketTask. This change may have introduced some behavioral differences in handling networking errors during background and foreground operations. I have done some additional testing with the device disconnected from Xcode. It seems that some updates made while the device is in background mode are not received. However, once the device returns to the foreground, all subsequent updates are received. I am currently testing with the branch Are you experiencing the same behavior, or are you finding that updates are not received regardless of whether they are made while the device is in the background or when it returns to the foreground? |
I have tested the following case, which is very important for our app: Device A loads data from the DataStore and displays it. The app goes then in the background. |
@tobias-feldmann Thanks for the information, is this something that you tested on Di's branch |
Hi @harsh62 |
@tobias-feldmann Thanks for clarifying. Our team will further investigate and provide an update as soon as we have one. |
Hi @tobias-feldmann , I've updated the branch |
Hi @5d I have just tested it. I had the following errors in the log. If it is relevant for you:
|
Hi @tobias-feldmann , With the The second error is necessary to notify the sync engine that the network has been interrupted and needs to restart. I am currently preparing the integration test and will create the PR for this. I will inform you once the patch is released. |
Hi @tobias-feldmann , The fix patch has been released in version 2.37.0. I'll go ahead and close this issue for now, but feel free to reopen it if the problem persists. |
Describe the bug
after upgrade to 2.92.2, iOS application can not receive update Subscription if application switch to background before. 2.17 SDK version is okay.
Steps To Reproduce
Expected behavior
Application switch to background and then go to foreground, it should can receive update/delete Subscription event.
Amplify Framework Version
2.29.2
Amplify Categories
DataStore
Dependency manager
Swift PM
Swift version
5.0
CLI version
12.1.1
Xcode version
15.3
Relevant log output
Subscription received mutation: MutationEvent(id: "090D92A4-0B9F-40A4-AF48-E59D9E189784", modelId: "5A727AAF-B629-42FE-9242-70779BB7D5CD", modelName: "ImageVideo", json: "{\"album\":\"IMG_2367.PNG\",\"dateAdded\":\"2024-04-25T09:09:59.000Z\",\"dateBackup\":\"2024-04-25T09:14:02.818Z\",\"dateModified\":\"2024-04-25T09:10:00.094Z\",\"dateTaken\":\"2024-04-25T09:09:59.000Z\",\"duration\":0,\"hash\":\"8a55a76fd67c92b9f68846f6a7e3b190\",\"height\":2436,\"id\":\"5A727AAF-B629-42FE-9242-70779BB7D5CD\",\"isdeleted\":true,\"localPath\":\"IMG_2367.PNG\",\"mimeType\":\"image\\/png\",\"orientation\":1,\"roomId\":\"2\",\"s3Data\":\"2\\/image_video\\/8a55a76fd67c92b9f68846f6a7e3b190.PNG\",\"size\":\"6708712\",\"title\":\"IMG_2367.PNG\",\"tn1S3Data\":\"2\\/tn\\/image_video\\/8a55a76fd67c92b9f68846f6a7e3b190_web.jpg\",\"type\":2,\"updatedAt\":\"2024-04-25T09:14:02.818Z\",\"userId\":\"ap-northeast-1:e1e5ac7d-281f-4da8-bef9-cc71f42b17fc\",\"width\":1125}", mutationType: "update", createdAt: Amplify.Temporal.DateTime(foundationDate: 2024-04-25 09:14:03 +0000, timeZone: Optional(GMT (fixed))), version: Optional(2), inProcess: false, graphQLFilterJSON: nil) now we can not receive such above Subscription if before application go to background.
Is this a regression?
Yes
Regression additional context
2.17 SDK do not happen such issue.
Platforms
iOS
OS Version
16.0~17.3
Device
iPhoneX/iPhone XR
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: