Closed raphire08 closed 1 year ago
Hi we'll need more information to know what is going on.
A NS internal consistency exception is a general exception thrown when an internal assertion fails.
Does this issue happen on the iOS simulator at all?
Does it happen on a test deploy to a iOS device from Xcode?
Does it affect all devices you run your app on?
Does your app crash on startup or when you click on a button, etc.
Full log of error message.
What code do you use for graphql?
@fjnoyp
This issue is currently coming in crashlytics console. It is currently faced by end users in their devices. We have not tried this in simulator yet. I am not sure if this is device specific issue. Seems like if certain conditions are met, it will happen in all the iOS devices.
The log messages are attached above in additional context. May be this can help
4 amplify_api_ios 0x15218 thunk for https://github.com/escaping @callee_unowned @convention(block) (https://github.com/unowned Swift.AnyObject?) -> () ()
5 amplify_api_ios 0x154b4 GraphQLSubscriptionsStreamHandler.sendEvent(payload🆔type:) ()
6 amplify_api_ios 0xe768 closure https://github.com/aws-amplify/amplify-flutter/pull/2 in static FlutterGraphQLApi.createOperation(bridge:flutterResult:graphQLSubscriptionsStreamHandler🆔request:) + 213 (FlutterGraphQLApi.swift:213)
7 Amplify 0x18d54 closure https://github.com/aws-amplify/amplify-flutter/pull/1 in AmplifyOperation.subscribe(resultListener:)
8 Amplify 0x196c4 partial apply for closure https://github.com/aws-amplify/amplify-flutter/pull/1 in AmplifyOperation.subscribe(resultListener:) ()
9 Amplify 0xbb1c8 closure https://github.com/aws-amplify/amplify-flutter/pull/1 in SerialDispatcher.dispatch(to:) + 46 (SerialDispatcher.swift:46)
Code at our end
String subscriptionDocument = getSubscriptionModel();
Map<String, dynamic> variables =
getVariables(ids.userId, ids.tenantId);
_stream = Amplify.API.subscribe(
GraphQLRequest<String>(
apiName: appSyncApiName,
document: subscriptionDocument,
variables: variables),
onEstablished: () {
Log.logInfo('AppSync connection established');
},
);
_subscription = _stream?.listen((event) {
onData(event, syncReading);
}, onDone: () {
Log.logInfo('AppSync connection closed');
}, onError: (e, s) {
Log.logError('Error in AppSync connection',
exception: e, stackTrace: s);
});
We have to close subscription and resubscribe on every app background/foreground operation and on network disconnection.
Hi @raphire08
Can you please provide the entire exception stacktrace and more information on the exception. At this point all I know is it's an NSInternalInconsistencyException which doesn't give me much information on what was inconsistent.
The log messages provided also don't give much information. I don't see any crash information within them, they just seem to be normal running logs. Where did you get those logs from?
Also is this a fatal exception or just an exception being logged in Firebase Crashlytics?
Regarding your code, can you please provide the subscriptionDocument you generate and also the code that closes subscription/resubscribes.
Thanks!
@fjnoyp
In firebase crashlytics it is coming under crashes
I am submitting the entire stack trace from crashlytics here
'''
subscription OnSubscriptionEvent(\$userId: String, \$tenantId: String) {
onSubscriptionEvent(userId: \$userId, tenantId: \$tenantId) {
eventData
eventType
tenantId
userId
}
}
''';
if (_stream != null) {
_subscription?.cancel().then((value) {
Log.logInfo('app sync cancelled');
});
_stream = null;
}
Resubscription is same function as mentioned above
Thanks
Thanks @raphire08 . Do you have any more information on how to reproduce this issue as well?
It seems like it's being registered in your Firebase Crashlytics. What % of unique users are affected by this crash?
@fjnoyp We are still trying to reproduce this at our end. If we found reproduction steps we will mention here. 10% of the users are getting effected. But Firebase is mentioning this as 100% background. I guess it means that device was in background state but I could not find firebase documentation mentioning this somewhere
@raphire08 a few more questions/comments to help reproduce. I've been looking at some other issues with GraphQL subscriptions in background on iOS and have generally noticed they are more likely to repro on a physical device, not simulator. I still haven't reprod this one, but sharing in case that helps on your end.
Regarding your cancel call, could you share more info/code about how you are calling it? Are you using WidgetsBindingObserver
to detect foreground/bacground events? Do you mind sharing the code that actually calls the cancel method so it can help us repro?
hi @ragingsquirrel3
Thanks for heads up we will try to reproduce in device only. Do you think it could depend on debug mode or release mode. For some instances of background / foreground operation I have seen different behaviour for different modes.
Please find the code for cancel. Thanks
Thanks for info. I still wasn't able to reproduce with this example in both debug mode and release mode (not sure if that would have any effect). Please update here if you find a good way to reproduce.
@raphire08 - If you are still facing this issue can you see if you are able to reproduce this with the latest version of Amplify Flutter? If you are using flutter 3.10 or higher you can use v1.1.0. If you are using Flutter 3.3 or 3.7 you can use v1.0.1
@Jordan-Nelson Thanks for the update. We will switch to Amplify 1.x.x libraries soon and then we can know if it is still coming or not.
@raphire08 - I am going to close this since I believe it will be resolved in v1. If you upgrade and are still facing an issue please let me know and we can reopen the issue.
Description
iOS Flutter App is crashing on production. Seems to be related to GaaphQL API. We are using AppSync to get notifications from server.
Categories
Steps to Reproduce
Not able to reproduce yet. Need help in reproduction. This is coming from swift library.
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
iPhone XR
OS
iOS 16.1.1
Deployment Method
Amplify CLI
CLI Version
No response
Additional Context
Logs captured from crashlytics
Amplify Config
{ "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "auth": { "plugins": { "awsCognitoAuthPlugin": { "UserAgent": "aws-amplify/cli", "Version": "0.1.0", "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "PoolId": "xxxxx", "AppClientId": "xxxxx", "AppClientSecret": "xxxxx", "Region": "xxxx" } }, "Auth": { "Default": { "authenticationFlowType": "USER_SRP_AUTH" } } } } }, "api": { "plugins": { "awsAPIPlugin": { "xxx": { "endpointType": "GraphQL", "endpoint": "xxx", "region": "xxx", "authorizationType": "AMAZON_COGNITO_USER_POOLS" } } } } }''';