У меня есть приложение для iOS, которое использует AWS Cognito для аутентификации пула пользователей на основе кода awslabs aws-sdk-ios-samples.
Обычно он работает нормально, но начиная с iOS 13.1.2, при каждом отзыве токена обновления происходит сбой приложения при попытке загрузить контроллер навигации.
Похоже, что AWSCognito
startPasswordauthentication
функция вызывается в фоновом потоке, но только когда попытка входа в систему возвращает {"__type":"NotAuthorizedException","message":"Refresh Token has been revoked"}
Помещение всей функции startPasswordauthentication
в Dispatchqueue.main.async {}
не позволит мне скомпилировать.
func startPasswordAuthentication() -> AWSCognitoIdentityPasswordAuthentication {
print("Starting Cognito Password Authentication")
if (self.navigationController?.restorationIdentifier != "signinController") {
self.navigationController = self.authstoryboard?.instantiateViewController(withIdentifier: "signinController") as? UINavigationController
}
if (self.signInViewController == nil) {
self.signInViewController = self.navigationController?.viewControllers[0] as? SignInViewController
}
DispatchQueue.main.async {
self.window?.rootViewController = self.navigationController
self.navigationController!.popToRootViewController(animated: true)
if (!self.navigationController!.isViewLoaded
|| self.navigationController!.view.window == nil) {
self.window?.rootViewController?.present(self.navigationController!,
animated: true,
completion: nil)
}
}
return self.signInViewController!
}
Возвращает аварийный дамп
Main Thread Checker: UI API called on a background thread: -[UIActivityIndicatorView initWithActivityIndicatorStyle:]
PID: 5625, TID: 1837740, Thread name: (none), Queue name: NSOperationQueue 0x145e7cff0 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4 iParcelBox 0x000000010489df64 $sSo23UIActivityIndicatorViewC5styleABSo0abC5StyleV_tcfcTO + 40
5 iParcelBox 0x0000000104894870 $sSo23UIActivityIndicatorViewC5styleABSo0abC5StyleV_tcfC + 52
6 iParcelBox 0x0000000104894c5c $s10iParcelBox11ProgressHUDC4textACSS_tcfc + 220
7 iParcelBox 0x0000000104894b70 $s10iParcelBox11ProgressHUDC4textACSS_tcfC + 68
8 iParcelBox 0x0000000104730d30 $s10iParcelBox20SignInViewControllerC5coderACSgSo7NSCoderC_tcfc + 992
9 iParcelBox 0x0000000104730ed0 $s10iParcelBox20SignInViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 60
10 UIKitCore 0x00000001c708e108 B856439D-6DF2-38FE-9689-E4C590AF1442 + 7123208
11 UIFoundation 0x00000001c694d300 601DB17B-4B17-30A9-962A-D27A531F470C + 447232
12 UIFoundation 0x00000001c694d534 601DB17B-4B17-30A9-962A-D27A531F470C + 447796
13 UIFoundation 0x00000001c68e7fe4 601DB17B-4B17-30A9-962A-D27A531F470C + 32740
14 UIKitCore 0x00000001c708d3fc B856439D-6DF2-38FE-9689-E4C590AF1442 + 7119868
15 UIKitCore 0x00000001c6dbd260 B856439D-6DF2-38FE-9689-E4C590AF1442 + 4170336
16 UIKitCore 0x00000001c6d17698 B856439D-6DF2-38FE-9689-E4C590AF1442 + 3491480
17 UIKitCore 0x00000001c708e108 B856439D-6DF2-38FE-9689-E4C590AF1442 + 7123208
18 UIFoundation 0x00000001c694d300 601DB17B-4B17-30A9-962A-D27A531F470C + 447232
19 UIFoundation 0x00000001c68e7fe4 601DB17B-4B17-30A9-962A-D27A531F470C + 32740
20 UIKitCore 0x00000001c70922b4 B856439D-6DF2-38FE-9689-E4C590AF1442 + 7140020
21 UIFoundation 0x00000001c694d300 601DB17B-4B17-30A9-962A-D27A531F470C + 447232
22 UIFoundation 0x00000001c694d534 601DB17B-4B17-30A9-962A-D27A531F470C + 447796
23 UIFoundation 0x00000001c68e7fe4 601DB17B-4B17-30A9-962A-D27A531F470C + 32740
24 UIKitCore 0x00000001c708d1e0 B856439D-6DF2-38FE-9689-E4C590AF1442 + 7119328
25 UIKitCore 0x00000001c708fe18 B856439D-6DF2-38FE-9689-E4C590AF1442 + 7130648
26 UIKitCore 0x00000001c7562054 B856439D-6DF2-38FE-9689-E4C590AF1442 + 12185684
27 iParcelBox 0x000000010489a20c $s10iParcelBox11AppDelegateC27startPasswordAuthenticationSo018AWSCognitoIdentityfG0_pyF + 1684
28 iParcelBox 0x000000010489b63c $s10iParcelBox11AppDelegateC27startPasswordAuthenticationSo018AWSCognitoIdentityfG0_pyFTo + 40
29 AWSCognitoIdentityProvider 0x00000001085a63fc -[AWSCognitoIdentityUser interactiveAuth] + 1312
30 AWSCognitoIdentityProvider 0x000000010859fd7c __36-[AWSCognitoIdentityUser getSession]_block_invoke + 224
31 AWSCore 0x0000000108875708 __56-[AWSTask continueWithExecutor:block:cancellationToken:]_block_invoke + 108
32 AWSCore 0x000000010881e444 __30+[AWSExecutor defaultExecutor]_block_invoke_2 + 164
33 AWSCore 0x000000010881ed0c -[AWSExecutor execute:] + 120
34 AWSCore 0x0000000108875b7c __56-[AWSTask continueWithExecutor:block:cancellationToken:]_block_invoke.105 + 52
35 AWSCore 0x000000010887515c -[AWSTask runContinuations] + 532
36 AWSCore 0x0000000108874c28 -[AWSTask trySetError:] + 256
37 AWSCore 0x0000000108876b78 -[AWSTaskCompletionSource setError:] + 112
38 AWSCore 2019-11-09 08:13:24.078227+0000 iParcelBox[5625:1837740] [reports] Main Thread Checker: UI API called on a background thread: -[UIActivityIndicatorView initWithActivityIndicatorStyle:]