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

iOS sync stop when app is in background and screen off only in Release #5041

Closed
2 of 14 tasks
JeremyLabelIO opened this issue Jun 20, 2024 · 16 comments
Closed
2 of 14 tasks
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced datastore Issues related to the DataStore Category iOS Issues specific to the iOS Platform

Comments

@JeremyLabelIO
Copy link

Description

Hi,

After updating amplify_flutter and amplify_datastore from 1.8.0 to 2.1.0 if I put my iOS app in background, turn off the screen, the sync is completely stopped. The only way to start sync again is to kill the app and relaunch it.

Everything works fine in debug but not in release.

I already try this :

As of next steps, please enable optimizations in your debug build and see if the issue is occurring when enabling the optimization. In addition, by using this way you will be able to obtain logs regarding the issue:
https://github.com/apple/swift/blob/main/docs/OptimizationTips.rst#enabling-optimizations

  • "In the Project Navigator, select the project icon to enter the Project Editor. In the project editor, select the icon under the "Project" header to enter the project settings editor. From there, an optimization setting can be applied to every target in the project by changing the "Optimization Level" field under the "Build Settings" header."

But I have still no logs and no changes.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.1 23B74 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)

Pubspec :

environment:
sdk: '>=3.3.0 <4.0.0'

dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
flutter_launcher_icons:
intl: ^0.19.0
amplify_flutter: 2.1.0
amplify_datastore: 2.1.0
amplify_api: 2.1.0
amplify_auth_cognito: 2.1.0
amplify_storage_s3: 2.1.0

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Start the app on your iPhone and check sync work normally.
  2. Put the app in background
  3. Turn off the screen
  4. Do some changes in another device
  5. Reopen the app on your iPhone
  6. You do not receive any update from the cloud
  7. If you want to have update again, you have to kill the app and relaunch it.

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.22.2

Amplify Flutter Version

2.1.0

Deployment Method

Amplify CLI

Schema

No response

@tyllark
Copy link
Member

tyllark commented Jun 20, 2024

Hello @JeremyLabelIO thank you for submitting this issue. We will look into this and get back to you!

@tyllark tyllark added datastore Issues related to the DataStore Category pending-triage This issue is in the backlog of issues to triage labels Jun 20, 2024
@Equartey
Copy link
Member

Hi @JeremyLabelIO,

Are you pausing the app during a sync? Or do you lose sync functionality when pausing the app?

DataStore changed in 2.1.0 to use our Dart first API category instead of using Amplify Swift under the hood. I suspect subscriptions management differs, specifically when the app isn't in the foreground.

In the meantime, give one of these two workarounds a try.

  1. Manage sync yourself during the App's lifecycle. For example, call start/stop DataStore when the app is being pause/resumed.
  2. Amplify Flutter 2.0.0 uses Amplify Swift and may unblock you in the interim.

These are just my initial thoughts. We'll provide a more concrete solution once we've looked into it more.

@tyllark tyllark added the to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided label Jun 20, 2024
@JeremyLabelIO
Copy link
Author

Hi @Equartey

I already try to stop and start DataStore when the app is being pause/resumed but without success.

I confirm it is working with Amplify Flutter 2.0.0 but I have other issue with this version (mostly in Android) and it is complicated for us to maintain different version for iOS and Android.

Do you think it will be fix soon ?

Best Regards,

Jeremy

@tyllark tyllark added bug Something is not working; the issue has reproducible steps and has been reproduced and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided pending-triage This issue is in the backlog of issues to triage labels Jun 21, 2024
@tyllark
Copy link
Member

tyllark commented Jun 21, 2024

Hi @JeremyLabelIO

I was able to reproduce the syncing issue following the steps you provided. We will track this as a bug and will let you know if there are any updates.

@JeremyLabelIO
Copy link
Author

Hi @tyllark

Thanks a lot.

@tyllark
Copy link
Member

tyllark commented Jun 25, 2024

No problem, we will let you know when we have an update.

@gauravwagh1
Copy link

Hello @tyllark

We are encountering the same issue with API (GraphQL) subscriptions, where the sync stops when the app is in the background or the screen is off (only in Release mode). Could you please provide any updates on when this issue might be resolved?

Thank you!

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Sep 24, 2024
@khatruong2009 khatruong2009 added the iOS Issues specific to the iOS Platform label Sep 26, 2024
@khatruong2009
Copy link
Member

Hi @gauravwagh1, we are still working to determine the root cause and will get back to you with any updates.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Sep 26, 2024
@Equartey
Copy link
Member

Equartey commented Oct 1, 2024

Hi @JeremyLabelIO,

I already try to stop and start DataStore when the app is being pause/resumed but without success.

A bug was fixed in Amplify DataStore 2.4.1 that resolved this workaround. Can you give it another try on this version?

@NikaHsn
Copy link
Member

NikaHsn commented Oct 16, 2024

I'm going to close this issue as we've released a fix for it. If you have additional questions, please open a new issue.

@NikaHsn NikaHsn closed this as completed Oct 16, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@tyllark
Copy link
Member

tyllark commented Oct 17, 2024

Hello @JeremyLabelIO and @gauravwagh1 sorry for the delay but we now have a fix for this issue under review. We will provide updates here when the fix is release, but in the meantime you can override your dependencies with the fix by including the following in your pubspec.yaml.

dependency_overrides:
  amplify_api:
    git:
      url: https://github.com/aws-amplify/amplify-flutter
      ref: fix/app-life-cycle-datastore-websockets
      path: packages/api/amplify_api
  
  amplify_api_dart:
    git:
      url: https://github.com/aws-amplify/amplify-flutter
      ref: fix/app-life-cycle-datastore-websockets
      path: packages/api/amplify_api_dart

Please let us know if you have any issues with this workaround.

@gauravwagh1
Copy link

Hello @JeremyLabelIO and @gauravwagh1 sorry for the delay but we now have a fix for this issue under review. We will provide updates here when the fix is release, but in the meantime you can override your dependencies with the fix by including the following in your pubspec.yaml.

dependency_overrides:
  amplify_api:
    git:
      url: https://github.com/aws-amplify/amplify-flutter
      ref: fix/app-life-cycle-datastore-websockets
      path: packages/api/amplify_api
  
  amplify_api_dart:
    git:
      url: https://github.com/aws-amplify/amplify-flutter
      ref: fix/app-life-cycle-datastore-websockets
      path: packages/api/amplify_api_dart

Please let us know if you have any issues with this workaround.

@tyllark
Thank you so much for the workaround. I’ve tested it by overriding the dependencies as suggested, and it’s working well on our end.
Do you have an estimated timeline for the official release of this fix? It would be helpful to know if there’s an ETA available.

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Oct 18, 2024
@tyllark
Copy link
Member

tyllark commented Oct 18, 2024

Hi @gauravwagh1 I just merged the changes. I will aim to schedule a release early next week. We will post here when the release is live.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Oct 18, 2024
@tyllark
Copy link
Member

tyllark commented Oct 22, 2024

Hello @JeremyLabelIO and @gauravwagh1 the fix has been released! Please update your packages to 2.4.2.

@tyllark tyllark closed this as completed Oct 22, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

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 iOS Issues specific to the iOS Platform
Projects
None yet
Development

No branches or pull requests

6 participants