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

App crash when using datastore with api sync and internet is offline #1816

Closed
2 of 9 tasks
yazoonic opened this issue Jun 24, 2022 · 24 comments
Closed
2 of 9 tasks

App crash when using datastore with api sync and internet is offline #1816

yazoonic opened this issue Jun 24, 2022 · 24 comments
Assignees
Labels
datastore Issues related to the DataStore Category not-reproducible Issues that cannot be reproduced using the steps provided pending-triage This issue is in the backlog of issues to triage

Comments

@yazoonic
Copy link

Description

using datastore with api sync for cloud, when you disconnect internet and add entries to data store, it will work momentary then app crash

I/amplify:aws-datastore(27749): Orchestrator transitioning from SYNC_VIA_API to LOCAL_ONLY
I/amplify:aws-datastore(27749): Setting currentState to LOCAL_ONLY
I/amplify:aws-datastore(27749): Stopping subscription processor.
I/amplify:aws-datastore(27749): Stopped subscription processor.
W/amplify:aws-datastore(27749): API sync failed - transitioning to LOCAL_ONLY.
W/amplify:aws-datastore(27749): DataStoreException{message=Error during subscription., cause=ApiException{message=Interrupted waiting for Cognito Userpools token., cause=java.lang.InterruptedException, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Evaluate details.}
W/amplify:aws-datastore(27749): at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$subscription$3(AppSyncClient.java:331)
W/amplify:aws-datastore(27749): at com.amplifyframework.datastore.appsync.AppSyncClient$$ExternalSyntheticLambda1.accept(Unknown Source:4)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation.lambda$null$1$com-amplifyframework-api-aws-SubscriptionOperation(SubscriptionOperation.java:87)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation$$ExternalSyntheticLambda0.accept(Unknown Source:4)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(SubscriptionEndpoint.java:131)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation.lambda$start$2$com-amplifyframework-api-aws-SubscriptionOperation(SubscriptionOperation.java:77)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation$$ExternalSyntheticLambda3.run(Unknown Source:2)
W/amplify:aws-datastore(27749): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/amplify:aws-datastore(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/amplify:aws-datastore(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/amplify:aws-datastore(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/amplify:aws-datastore(27749): at java.lang.Thread.run(Thread.java:919)
W/amplify:aws-datastore(27749): Caused by: ApiException{message=Interrupted waiting for Cognito Userpools token., cause=java.lang.InterruptedException, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.fetchToken(DefaultCognitoUserPoolsAuthProvider.java:90)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.getLatestAuthToken(DefaultCognitoUserPoolsAuthProvider.java:104)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.forCognitoUserPools(SubscriptionAuthorizer.java:147)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.createHeaders(SubscriptionAuthorizer.java:96)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.createHeadersForConnection(SubscriptionAuthorizer.java:71)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.buildConnectionRequestUrl(SubscriptionEndpoint.java:300)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(SubscriptionEndpoint.java:127)
W/amplify:aws-datastore(27749): ... 7 more
W/amplify:aws-datastore(27749): Caused by: java.lang.InterruptedException
W/amplify:aws-datastore(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
W/amplify:aws-datastore(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
W/amplify:aws-datastore(27749): at java.util.concurrent.Semaphore.acquire(Semaphore.java:318)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.fetchToken(DefaultCognitoUserPoolsAuthProvider.java:88)
W/amplify:aws-datastore(27749): ... 13 more
W/System.err(27749): io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.RuntimeException: java.lang.InterruptedException
W/System.err(27749): at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:78)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:43)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
W/System.err(27749): at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:614)
W/System.err(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
W/System.err(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
W/System.err(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(27749): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W/System.err(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(27749): at java.lang.Thread.run(Thread.java:919)
W/System.err(27749): Caused by: java.lang.RuntimeException: java.lang.InterruptedException
W/System.err(27749): at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
W/System.err(27749): at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:94)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3645)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.resolvePredicates(QueryPredicateProvider.java:64)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$3$com-amplifyframework-datastore-syncengine-Orchestrator(Orchestrator.java:298)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.Orchestrator$$ExternalSyntheticLambda5.subscribe(Unknown Source:2)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
W/System.err(27749): ... 16 more
W/System.err(27749): Caused by: java.lang.InterruptedException
W/System.err(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
W/System.err(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
W/System.err(27749): at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.buildSyncExpressions$lambda-39$lambda-38(AmplifyDataStorePlugin.kt:540)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.$r8$lambda$UO16rzDLOMeK1HlIWQ6n_FUcSvk(Unknown Source:0)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin$$ExternalSyntheticLambda12.resolvePredicate(Unknown Source:6)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.lambda$resolvePredicates$0(QueryPredicateProvider.java:62)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider$$ExternalSyntheticLambda2.apply(Unknown Source:2)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:58)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable$FromIterableDisposable.run(ObservableFromIterable.java:98)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:58)
W/System.err(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:33)
W/System.err(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableCollectSingle.subscribeActual(ObservableCollectSingle.java:50)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3644)
W/System.err(27749): ... 20 more
E/AndroidRuntime(27749): FATAL EXCEPTION: RxCachedThreadScheduler-24
E/AndroidRuntime(27749): Process: com.pinsbasket.walletin, PID: 27749
E/AndroidRuntime(27749): io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.RuntimeException: java.lang.InterruptedException
E/AndroidRuntime(27749): at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:78)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:43)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:614)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
E/AndroidRuntime(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(27749): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
E/AndroidRuntime(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(27749): at java.lang.Thread.run(Thread.java:919)
E/AndroidRuntime(27749): Caused by: java.lang.RuntimeException: java.lang.InterruptedException
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:94)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3645)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.resolvePredicates(QueryPredicateProvider.java:64)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$3$com-amplifyframework-datastore-syncengine-Orchestrator(Orchestrator.java:298)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.Orchestrator$$ExternalSyntheticLambda5.subscribe(Unknown Source:2)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
E/AndroidRuntime(27749): ... 16 more
E/AndroidRuntime(27749): Caused by: java.lang.InterruptedException
E/AndroidRuntime(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
E/AndroidRuntime(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
E/AndroidRuntime(27749): at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.buildSyncExpressions$lambda-39$lambda-38(AmplifyDataStorePlugin.kt:540)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.$r8$lambda$UO16rzDLOMeK1HlIWQ6n_FUcSvk(Unknown Source:0)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin$$ExternalSyntheticLambda12.resolvePredicate(Unknown Source:6)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.lambda$resolvePredicates$0(QueryPredicateProvider.java:62)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider$$ExternalSyntheticLambda2.apply(Unknown Source:2)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:58)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable$FromIterableDisposable.run(ObservableFromIterable.java:98)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:58)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:33)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableCollectSingle.subscribeActual(ObservableCollectSingle.java:50)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3644)
E/AndroidRuntime(27749): ... 20 more
I/Process (27749): Sending signal. PID: 27749 SIG: 9

Categories

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

Steps to Reproduce

  1. config your app to use datastore with api sync for cloud.
  2. open the app and complete sync.
  3. disable wifi or whatever internet you are using.
  4. add entries to your app (you may need to add 10 entries)
  5. app will crash

Screenshots

No response

Platforms

  • iOS
  • Android

Android Device/Emulator API Level

No response

Environment

flutter doctor --verbose
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.3.1 21E258 darwin-x64, locale en-US)
    • Flutter version 3.0.2 
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (2 weeks ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK 
    • Platform android-32, build-tools 31.0.0
    • ANDROID_HOME 
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! CocoaPods 1.9.2 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.66.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • Pixel XL (mobile)                • HT6AD0202995  • android-arm64  • Android 10 (API 29)
   

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
Process finished with exit code 0

Dependencies

flutter pub deps --no-dev --style=compact
Dart SDK 2.17.3
Flutter SDK 3.0.2


dependencies:
- amplify_api 0.5.1 [amplify_api_plugin_interface amplify_core amplify_api_android amplify_api_ios collection flutter meta plugin_platform_interface]
- amplify_auth_cognito 0.5.1 [amplify_auth_cognito_android amplify_auth_cognito_ios amplify_auth_plugin_interface amplify_core collection flutter plugin_platform_interface]
- amplify_datastore 0.5.1 [flutter amplify_datastore_plugin_interface amplify_core plugin_platform_interface meta collection async]
- amplify_flutter 0.5.1 [amplify_analytics_plugin_interface amplify_api_plugin_interface amplify_auth_plugin_interface amplify_core amplify_datastore_plugin_interface amplify_flutter_android amplify_flutter_ios amplify_storage_plugin_interface collection flutter json_annotation meta plugin_platform_interface]
- connectivity_plus 2.3.5 [flutter connectivity_plus_platform_interface connectivity_plus_linux connectivity_plus_macos connectivity_plus_web connectivity_plus_windows]
- cupertino_icons 1.0.5
- dots_indicator 2.1.0 [flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_lints 2.0.1 [lints]
- intl 0.17.0 [clock path]
- introduction_screen 3.0.2 [flutter dots_indicator collection]
- math_expressions 2.3.1 [vector_math]
- provider 6.0.3 [collection flutter nested]
- purchases_flutter 3.10.0 [flutter freezed_annotation json_annotation]
- shared_preferences 2.0.15 [flutter shared_preferences_android shared_preferences_ios shared_preferences_linux shared_preferences_macos shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- syncfusion_flutter_charts 20.1.61 [flutter intl vector_math syncfusion_flutter_core]
- url_launcher 6.1.4 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]

transitive dependencies:
- amplify_analytics_plugin_interface 0.5.1 [amplify_core flutter meta]
- amplify_api_android 0.5.1 [flutter]
- amplify_api_ios 0.5.1 [amplify_core flutter]
- amplify_api_plugin_interface 0.5.1 [amplify_core collection flutter json_annotation meta]
- amplify_auth_cognito_android 0.5.1 [flutter]
- amplify_auth_cognito_ios 0.5.1 [amplify_core flutter]
- amplify_auth_plugin_interface 0.5.1 [amplify_core flutter meta]
- amplify_core 0.5.1 [collection date_time_format flutter meta plugin_platform_interface uuid]
- amplify_datastore_plugin_interface 0.5.1 [flutter meta collection amplify_core]
- amplify_flutter_android 0.5.1 [flutter]
- amplify_flutter_ios 0.5.1 [amplify_core flutter]
- amplify_storage_plugin_interface 0.5.1 [flutter meta amplify_core]
- args 2.3.1
- async 2.8.2 [collection meta]
- characters 1.2.0
- clock 1.1.0
- collection 1.16.0
- connectivity_plus_linux 1.3.1 [flutter connectivity_plus_platform_interface meta nm]
- connectivity_plus_macos 1.2.4 [connectivity_plus_platform_interface flutter]
- connectivity_plus_platform_interface 1.2.1 [flutter meta plugin_platform_interface]
- connectivity_plus_web 1.2.2 [connectivity_plus_platform_interface flutter_web_plugins flutter]
- connectivity_plus_windows 1.2.2 [connectivity_plus_platform_interface flutter]
- crypto 3.0.2 [typed_data]
- date_time_format 2.0.1
- dbus 0.7.5 [args ffi meta xml]
- ffi 2.0.1
- file 6.1.2 [meta path]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- freezed_annotation 1.1.0 [collection json_annotation meta]
- js 0.6.4
- json_annotation 4.5.0 [meta]
- lints 2.0.0
- material_color_utilities 0.1.4
- meta 1.7.0
- nested 1.0.0 [flutter]
- nm 0.5.0 [dbus]
- path 1.8.1
- path_provider_linux 2.1.7 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.0.4 [flutter platform plugin_platform_interface]
- path_provider_windows 2.1.0 [ffi flutter path path_provider_platform_interface win32]
- petitparser 5.0.0 [meta]
- platform 3.1.0
- plugin_platform_interface 2.1.2 [meta]
- process 4.2.4 [file path platform]
- shared_preferences_android 2.0.12 [flutter shared_preferences_platform_interface]
- shared_preferences_ios 2.1.1 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.1.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_macos 2.0.4 [flutter shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.0.0 [flutter]
- shared_preferences_web 2.0.4 [flutter flutter_web_plugins shared_preferences_platform_interface]
- shared_preferences_windows 2.1.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- syncfusion_flutter_core 20.1.61 [vector_math flutter]
- typed_data 1.3.1 [collection]
- url_launcher_android 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.0.17 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.0.1 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.1.0 [flutter plugin_platform_interface]
- url_launcher_web 2.0.12 [flutter flutter_web_plugins url_launcher_platform_interface]
- url_launcher_windows 3.0.1 [flutter url_launcher_platform_interface]
- uuid 3.0.6 [crypto]
- vector_math 2.1.2
- win32 2.7.0 [ffi]
- xdg_directories 0.2.0+1 [meta path process]
- xml 6.1.0 [collection meta petitparser]

Device

Pixel XL

OS

Android 10

CLI Version

7.6.26

Additional Context

No response

@fjnoyp fjnoyp added the datastore Issues related to the DataStore Category label Jun 24, 2022
@HuiSF
Copy link
Member

HuiSF commented Jun 25, 2022

Hi @yazoonic Thanks for reporting this issue. This is interesting...

We can see the main exception probably is java.lang.InterruptedException. This exception raised at multiple spots:

  1. amplify-flutter Android implementation buildSyncExpression
  2. amplify-android implementation resolvePredicates (This call be the upstream call to spot 1)
  3. aws-mobile-appsync-sdk implementation fetchToken

All of these spots are doing similar thing - requiring permit to wait on the thread.

I did a quick testing on Android emulator following your steps, I tried to add multiple entries after the emulator went to offline, and I couldn't reproduce the crash. Although I used API_KEY auth on the API which doesn't require fetch token step. Also... I don't have an android device so couldn't test further.

Noticeably the sync engine will try to resume connection on every save API call, not sure if back to back save call can cause any potential issue.

Need further investigation.

@HuiSF HuiSF added 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 25, 2022
@yazoonic
Copy link
Author

@HuiSF Thanks for looking into this.. just to confirm, I just tested with emulator and I have the same error.
and I use Cognito for authentication.

@yazoonic
Copy link
Author

@HuiSF I can confirm that the issue is not happening when I remove the selective sync expression, Please verify and let me know when this can be resolved

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

Thanks for the follow up @yazoonic how many sync expressions you are using? Can you share the code snippet that initialize the DataStore plugin with the sync expressions?

@yazoonic
Copy link
Author

@HuiSF I cant share the exact code but this what I used, I just replaced table name .. i have 17 tables...
i have table with QueryPredicate.all.. but I removed it with no luck.

AmplifyDataStore datastorePlugin = AmplifyDataStore(
modelProvider: ModelProvider.instance,
syncExpressions: [
DataStoreSyncExpression(Table1.classType, () => Table1.SUBID.eq(userID)),
DataStoreSyncExpression(Table2.classType, () => Table2.SUBID.eq(userID)),
DataStoreSyncExpression(Table3.classType, () => Table3.SUBID.eq(userID)),
DataStoreSyncExpression(Table4.classType, () => Table4.SUBID.eq(userID)),
DataStoreSyncExpression(Table5.classType, () => Table5.SUBID.eq(userID)),
DataStoreSyncExpression(Table6.classType, () => Table6.SUBID.eq(userID)),
DataStoreSyncExpression(Table7.classType, () => Table7.SUBID.eq(userID)),
DataStoreSyncExpression(Table8.classType, () => Table8.SUBID.eq(userID)),
DataStoreSyncExpression(Table9.classType, () => Table9.SUBID.eq(userID)),
DataStoreSyncExpression(Table10.classType, () => QueryPredicate.all),
DataStoreSyncExpression(Table11.classType, () => Table11.SUBID.eq(userID)),
DataStoreSyncExpression(Table12.classType, () => Table12.SUBID.eq(userID)),
DataStoreSyncExpression(Table13.classType, () => Table13.SUBID.eq(userID)),
DataStoreSyncExpression(Table14.classType, () => Table14.SUBID.eq(userID)),
DataStoreSyncExpression(Table15.classType, () => Table15.SUBID.eq(userID)),
DataStoreSyncExpression(Table16.classType, () => Table16.SUBID.eq(userID)),
DataStoreSyncExpression(Table17.classType, () => Table17.SUBID.eq(userID)),
]);

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

OK no problem @yazoonic
Can you also do me a favor?
Could you test with less sync expression in place, see if the crash happens?

DataStoreSyncExpression(Table10.classType, () => QueryPredicate.all),

This sync expression can be removed as it does the same as the default syncing behavior

Also are you syncing data based on userId in your real use cases? If this is true, I recommend you enable owner based auth to control data sync scope instead of using sync expressions.

@yazoonic
Copy link
Author

i will try to do with less eync expression... what do you mean by owner based auth? I have tables defined as below
type Templates @model @auth(rules: [{allow: private}]) {

and how to enable owner based auth?

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

Please follow this documentation: https://docs.amplify.aws/lib/datastore/setup-auth-rules/q/platform/flutter/#per-user--owner-based-data-access

When you enable owner based auth, only the models that belong to the currently signed in user will be synced into local database.

@yazoonic
Copy link
Author

oh I think I tired it before and I had a problem with my production app so I rolled back..

I will give it a try in my dev and see.

@yazoonic
Copy link
Author

so the problem with this one that if I pushed this update to my production database.. current app user will lose connectivity until I update the app code and push it to Apple app store which will take 1-2 days to approve ,,,,
so my current app users will have issues accessing the app without the update.
I am trying to find away to work around this.

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

Hum OK, changing auth to existing data in prod env is troublesome for sure.

@yazoonic
Copy link
Author

@HuiSF I tried with just one sync expression and I got crash as well.

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

Are you building the apk in release mode? @yazoonic

@yazoonic
Copy link
Author

before I wasnt .. but now I have the release mode on in build gradle and I just use the play button as debug... should I remove the settings for release?

@HuiSF
Copy link
Member

HuiSF commented Jun 27, 2022

before I wasnt .. but now I have the release mode on in build gradle and I just use the play button as debug... should I remove the settings for release?

I can't repro this on emulator myself, so I want to determine a possible cause with different permutation...
Are you using Android Studio? Can check the build mode from the menu: Build -> Select Build Variant

Also can you try run the App in a different emulator?

@yazoonic
Copy link
Author

I am using Android Studio... the build Variant is debug
I tired in physical device Google Pixel and Also in 2 different emulators. Strange!

is it something related to my Auth flow...

@yazoonic
Copy link
Author

@HuiSF do you have anyway to migrate from private to owner auth? I tired multi auth then update to owner and I cant access data

@HuiSF
Copy link
Member

HuiSF commented Jun 29, 2022

I tired in physical device Google Pixel and Also in 2 different emulators. Strange!

The crash happens in all these devices/emulators?

is it something related to my Auth flow...

It's possible, sorry I don't have time right now for a thorough testing, can dig in deeper next week.

do you have anyway to migrate from private to owner auth? I tired multi auth then update to owner and I cant access data

There is no easy way, here's the basic steps in my mind (rough)

  1. update schema to use owner based auth
  2. Determine which field in the model is the "owner field" (by default it's owner if you are not overriding it)
  3. Add owner field to existing DynamoDB records (Could be tricky as you need to determine which records belong to which user(owner), and add all the values)
  4. Test

If you are thinking about this, please test the migration in a pre-prod environment first.

Also how many records roughly do you have in each table?

@yazoonic
Copy link
Author

yazoonic commented Jul 1, 2022

@HuiSF yes the crash happening in all devices and simulators.

I have more than 5k records and growing for one table. other tables have less than 200 entries.

I am thinking of something else in migration by enabling multi auth with overriding owner field .. I have to test it though.

@yazoonic
Copy link
Author

@HuiSF any news?

@HuiSF
Copy link
Member

HuiSF commented Jul 27, 2022

Hi @yazoonic sorry for the delayed response. No substantial update on my side, as I couldn't reproduce this crash so I'm pretty much blind on debugging this crash.

@yazoonic
Copy link
Author

@HuiSF I was reading this thread again in your repro and you mentioned that you use API_key Auth which maybe the reason you were not able to repro.

@yazoonic
Copy link
Author

yazoonic commented Sep 8, 2022

@HuiSF I have tested flutter for this case with iPhone device and the crash is not happening.. seems like it is Android specific.

@Jordan-Nelson Jordan-Nelson added not-reproducible Issues that cannot be reproduced using the steps provided and removed to-be-reproduced Issues that have not been reproduced yet, but have reproduction steps provided labels Mar 28, 2023
@HuiSF
Copy link
Member

HuiSF commented Mar 28, 2023

We've merged a change to handle the exception shown in the logs, and the fix has been released with v0.6.11, which prevents the crash.

As we are not able to actual reproduce this crash, I'm optimistically closing this issue. Please feel free to follow up and open a new issue if any further assistance is need/

@HuiSF HuiSF closed this as completed Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore Category not-reproducible Issues that cannot be reproduced using the steps provided pending-triage This issue is in the backlog of issues to triage
Projects
None yet
Development

No branches or pull requests

4 participants