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

can not receive update Subscription event on 2.29.2 SDK version #3632

Open
smediomike opened this issue Apr 25, 2024 · 5 comments
Open

can not receive update Subscription event on 2.29.2 SDK version #3632

smediomike opened this issue Apr 25, 2024 · 5 comments
Assignees
Labels
bug Something isn't working datastore Issues related to the DataStore category pending-triage Issue is pending triage

Comments

@smediomike
Copy link

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

Steps to reproduce the behavior:
1, upgrade SDK to 2.29.2 
2, run application and go to background to take one picture
3, upload such picture to s3 storage, as this time, we can receive Subscription Add event, and datastore also can query such new record.
4, delete this item from web by grpahcGL
5, iOS application can not receive such Subscription event; on 2.17 SDK, we can receive such event. and also datastore can not sync such record till to re-start application.

possible root cause: 
our application go to background and then to foreground to upload and wait for update Subscription event. if we do not go to background and and do same steps, such issue do not happen.

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

@lawmicha
Copy link
Member

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?

@lawmicha lawmicha added bug Something isn't working datastore Issues related to the DataStore category pending-triage Issue is pending triage labels Apr 25, 2024
@smediomike
Copy link
Author

smediomike commented Apr 26, 2024

Hi @lawmicha

  1. Amplify.Publisher.create(Amplify.DataStore.observe(model))
  2. Amplify.Storage.uploadFile or Amplify.Storage.uploadData
  3. try await Amplify.DataStore.save(model)
  4. Received changes.mutationType "create" ==> this is correct on 2.29.2 which same to 2.17
  5. delete such content by API on client or on web and mask datastore one fileld to "deleted" status by the below iOS code:
     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)")
  1. we can see this content is be deleted, but we can not receive changes.mutationType "update" event on 2.29.2, but 2.17 can receive

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!

@smediomike
Copy link
Author

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.

@smediomike
Copy link
Author

Hi @lawmicha
add more information, I rollback SDK version to 2.26.1; this issue will not happen.

@lawmicha lawmicha self-assigned this Apr 30, 2024
@ruisebas
Copy link
Member

ruisebas commented May 6, 2024

Hi @smediomike,

We've recently addressed an issue that was causing network-related problems in the latest version 2.33.3.
Would you mind please upgrading to this version and verifying if it also addresses your issue?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datastore Issues related to the DataStore category pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

3 participants