Closed crawford-jake closed 2 years ago
Hi @crawford-jake thanks for reaching out. The stacktrace information is helpful but seems to suggest the operationsMap
field in OperationsManager.swift
is null - which shouldn't be possible. However, the code is called due to a apiError
from FlutterGraphQLApi.swift
. Would be interesting to know what this apiError
is.
Until you are able to reproduce, can you tell us what Rest API methods you are calling and where in the code you make those calls?
The iOS stacktrace shows the following lines are crashing:
FlutterGraphQLApi.swift -
case .failure(let apiError):
print("Subscription has terminated with \(apiError)")
if !id.isEmpty {
==> OperationsManager.removeOperation(cancelToken: id)
}
OperationsManager.swift -
public static func removeOperation(cancelToken: String) {
==> guard let operation = operationsMap[cancelToken] else {
return
}
@fjnoyp thanks for the information, this helps a lot! We will be trying to recreate this error over the next few days. I will post here on what we find.
We are also having this problem in our project with a different Stacktrace error. Currently this is happening for most of the users of our app using iPhone and iOS15 and it has become a very important blocker and priority internally
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
0 amplify_api 0x0000000102a36c8c $sSDyq_SgxcigSS_So11NSOperationCTg5 + 0 (<compiler-generated>:0)
1 amplify_api 0x0000000102a36c8c static OperationsManager.removeOperation(cancelToken:) + 84 (OperationsManager.swift:43)
2 amplify_api 0x0000000102a36c88 static OperationsManager.removeOperation(cancelToken:) + 80 (OperationsManager.swift:43)
3 amplify_api 0x0000000102a39830 $s11amplify_api17OperationsManagerO15cancelOperation0E5TokenySS_tFZ + 20 (OperationsManager.swift:81)
4 amplify_api 0x0000000102a39830 specialized SwiftAmplifyApiPlugin.onCancel(flutterResult:cancelToken:) + 696 (SwiftAmplifyApiPlugin.swift:149)
5 amplify_api 0x0000000102a386e8 $s11amplify_api21SwiftAmplifyApiPluginC8onCancel13flutterResult11cancelTokenyyypSgc_SStF + 16 (<compiler-generated>:0)
6 amplify_api 0x0000000102a386e8 SwiftAmplifyApiPlugin.innerHandle(method:callArgs:result:) + 180 (SwiftAmplifyApiPlugin.swift:59)
7 amplify_api 0x0000000102a38560 SwiftAmplifyApiPlugin.handle(_:result:) + 300 (SwiftAmplifyApiPlugin.swift:51)
8 amplify_api 0x0000000102a3860c @objc SwiftAmplifyApiPlugin.handle(_:result:) + 112 (<compiler-generated>:0)
9 Flutter 0x00000001033ed028 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 116
10 Flutter 0x0000000102f21a00 flutter::PlatformViewIOS::HandlePlatformMessage(std::__1::unique_ptr<flutter::PlatformMessage, std::__1::default_delete<flutter::PlatformMessage> >) + 516
11 Flutter 0x00000001032b39a4 std::__1::__function::__func<fml::internal::CopyableLambda<flutter::Shell::OnEngineHandlePlatformMessage(std::__1::unique_ptr<flutter::PlatformMessage, std::__1::default_delete<flutter::PlatformMes... + 92
12 Flutter 0x00000001031db908 fml::MessageLoopImpl::FlushTasks(fml::FlushType) + 1668
13 Flutter 0x00000001031deed4 fml::MessageLoopDarwin::OnTimerFire(__CFRunLoopTimer*, fml::MessageLoopDarwin*) + 32
14 CoreFoundation 0x0000000180e6a318 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 32 (CFRunLoop.c:1812)
15 CoreFoundation 0x0000000180deecf0 __CFRunLoopDoTimer + 1076 (CFRunLoop.c:2420)
16 CoreFoundation 0x0000000180de94ec __CFRunLoopDoTimers + 328 (CFRunLoop.c:2580)
17 CoreFoundation 0x0000000180dc7d08 __CFRunLoopRun + 1944 (CFRunLoop.c:3116)
18 CoreFoundation 0x0000000180ddb468 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3268)
19 GraphicsServices 0x000000019c97f38c GSEventRunModal + 164 (GSEvent.c:2200)
20 UIKitCore 0x000000018377e5d0 -[UIApplication _run] + 1100 (UIApplication.m:3493)
21 UIKitCore 0x00000001834fcf74 UIApplicationMain + 364 (UIApplication.m:5047)
22 Runner 0x00000001008ff628 main + 64 (AppDelegate.swift:5)
23 dyld 0x0000000100b55aa4 start + 520 (dyldMain.cpp:879)
----
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000001 x1: 0x000000016f5053b0 x2: 0x0000000102a36c88 x3: 0x0000000102a44708
x4: 0x0000000000000020 x5: 0x000000016f504c08 x6: 0x000000016f504d20 x7: 0x0000000000000000
x8: 0x0000000000000000 x9: 0x0000000000000000 x10: 0x03000001040d7bb5 x11: 0x04000001040d7bb5
x12: 0x000000000000014d x13: 0x00000000b302d9ca x14: 0x00000000b322e000 x15: 0x000000000002e000
x16: 0x0000000185b913d4 x17: 0xbbbf000101ac1278 x18: 0x00000001073d61c8 x19: 0x40000002811e7240
x20: 0x0000000102a44708 x21: 0xc000000000000024 x22: 0x8000000000000000 x23: 0xc000000000000024
x24: 0x000000010713b8a0 x25: 0x000000010713b8a0 x26: 0x000000000000002e x27: 0x00005f5d9eb119b9
x28: 0x000000016f5057f8 fp: 0x000000016f505420 lr: 0xae598e0102a36c88
sp: 0x000000016f5053b0 pc: 0x0000000102a36c8c cpsr: 0x60001000
esr: 0x92000006 (Data Abort) byte read Translation fault
We found in the CloudWatch logs that our subscriptions are passing an "Operation: null"
.
subscription mySub($userId: String!) {
getUser(userId: $userId) {
myStuff {
name
}
}
, Operation: null, Variables:
{
"userId": "123456"
}
@dnys1 Feedback from one of our cloud engineers: I started digging into amplify’s code, and since we get a null on removeOperation, that means that the operation is saved as a null when it is added. it gets added when we call Amplify.API.subscribe which executes this code and on line 161 its adding the operation (which is null) to a map.. so then on removeOperation when it gets the operation from the map, its getting a null value which means that createOperation on line 156 is returning null value.
We were able to crash the app by changing a lambda function to throw an error on a mutation. This crashed with the following:
Thread 16 name:
Thread 16 Crashed:
0 amplify_api 0x000000010416ac68 $sSDyq_SgxcigSS_So11NSOperationCTg5 + 0 (<compiler-generated>:0)
1 amplify_api 0x000000010416ac68 static OperationsManager.removeOperation(cancelToken:) + 84 (OperationsManager.swift:43)
2 amplify_api 0x000000010416ac64 static OperationsManager.removeOperation(cancelToken:) + 80 (OperationsManager.swift:43)
3 amplify_api 0x000000010415ff4c closure #2 in static FlutterGraphQLApi.createOperation(bridge:flutterResult:graphQLSubscriptionsStreamHandler:id:request:) + 456 (FlutterGraphQLApi.swift:210)
4 Amplify 0x0000000103581454 closure #1 in AmplifyOperation.subscribe(resultListener:) + 464 (AmplifyOperation.swift:131)
5 Amplify 0x0000000103581fec partial apply for closure #1 in AmplifyOperation.subscribe(resultListener:) + 36 (<compiler-generated>:0)
6 Amplify 0x000000010361e864 closure #1 in SerialDispatcher.dispatch(to:) + 96 (SerialDispatcher.swift:45)
7 Amplify 0x00000001035d2b00 thunk for @escaping @callee_guaranteed () -> () + 28 (<compiler-generated>:0)
8 libdispatch.dylib 0x00000001dd02ae68 _dispatch_call_block_and_release + 32 (init.c:1517)
9 libdispatch.dylib 0x00000001dd02ca2c _dispatch_client_callout + 20 (object.m:560)
10 libdispatch.dylib 0x00000001dd02fb44 _dispatch_queue_override_invoke + 784 (inline_internal.h:2622)
11 libdispatch.dylib 0x00000001dd03e164 _dispatch_root_queue_drain + 396 (inline_internal.h:0)
12 libdispatch.dylib 0x00000001dd03e96c _dispatch_worker_thread2 + 164 (queue.c:6935)
13 libsystem_pthread.dylib 0x000000024eaf6080 _pthread_wqthread + 228 (pthread.c:2612)
14 libsystem_pthread.dylib 0x000000024eaf5e5c start_wqthread + 8
Thread 16 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000001 x1: 0x000000016d6d6b30 x2: 0x000000010416ac64 x3: 0x000000010417b5c8
x4: 0x0000000000000020 x5: 0x00000001041c275c x6: 0x0000000283db7d00 x7: 0x0000000000000000
x8: 0x0000000000000000 x9: 0x0000000000000000 x10: 0x00000000fffffffe x11: 0x0000000237cac958
x12: 0x000000010366ab00 x13: 0x0000000000000000 x14: 0x000000010366aaf8 x15: 0x0000000236bb8450
x16: 0x00000001e2181bf0 x17: 0xe3ba000237cac4d8 x18: 0x0000000000000000 x19: 0x4000000283db6a00
x20: 0x000000010417b5c8 x21: 0xc000000000000024 x22: 0x8000000000000000 x23: 0x0000000283db7d00
x24: 0x00000001041c275c x25: 0x000000016d6d6cb0 x26: 0x000000010be24c80 x27: 0x0000000281d952e0
x28: 0x0000000282638e80 fp: 0x000000016d6d6ba0 lr: 0x6037ce810416ac64
sp: 0x000000016d6d6b30 pc: 0x000000010416ac68 cpsr: 0x60001000
esr: 0x92000006 (Data Abort) byte read Translation fault
Thanks, @crawford-jake - sorry for the inconvenience. We should have a fix out soon.
@dnys1 Was this fix released in 0.5.0?
Hi @crawford-jake - apologies for the delay on this. No, we have not released it yet. We are planning a release with this and a few other fixes either today or tomorrow. Thanks for your patience!
Sorry again for the delay getting this out. It's been released with v0.5.1
@dnys1 I have gotten same error with Ios version 14.2
and 14.3
, the screen is frozen. But I'm testing on real device ios 14.7
, 15.7
, simulator version 16.1
it work. Please help me to find what happened and how can fix it. Thanks
Hi @Ekoios-Teddy, this is a slightly different issue. Can you confirm you have updated your iOS target to 13.0 in your Xcode project? If so, can you create a new issue with the reproduction steps?
Yes, I have updated IOS target to 13.0 but it not work with any version Ios like 14.2
and 14.3
it not work.It work on 14.7
and 15.7
and 16.0
.I guess maybe it will work with version greater than 14.5 or 14.7 but I can't check others version
Gotcha. Without more information, it's hard to say what the issue is. The stack trace shows the Hosted UI callbacks being triggered from a background thread. I'm not exactly sure how this would happen and haven't seen it myself. Would you be able to create a new issue with the steps to reproduce and a code sample which I can experiment with?
Yes, i will create new issue about it. Humorously, it work with some version so i am not zoning this problem.
Description
We are getting reports of crashes from people using our app. The crash seems to occur when users have had the app open in the background for a very long time, but we also have reports of the app crashing after a short amount of time with the same error. From the log below, it appears amplify dereferences an invalid pointer. We have many other logs that all report the same crash in OperationsManager.swift. Additionally, this ONLY happens on devices running iOS 15. We have seen no issues on devices iOS 14 or lower, or on Android running the latest flutter amplify packages.
Categories
Steps to Reproduce
We are still working on a way to reproduce this.
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
iPhone 12, iPhone 13
OS
iOS 15 ONLY
CLI Version
7.6.26
Additional Context
We are still attempting to create reproduction steps, however we are hoping the log above may help in determining a root cause.