iOS SDK에서 Concurrency 사용시 app crash

KakaoOpenSDK - 2.24.0
App ID - 573044
문의 시, 사용하시는 SDK 버전 정보와 디벨로퍼스 앱ID를 알려주세요.


앱에서 Concurrency 사용을 위해서 UserApi.shared.loginWithKakaoTalk 를 withCheckedThrowingContinuation로 감싸서 사용중인데 crash Report로
CheckedContinuation.resume(returning:)
CheckedContinuation.resume(throwing:)
이 간혈적으로 잡히고 있습니다.
함수는 아래와 같이 감싸져있는데 이유를 알 수 있을까요 ??

@MainActor
func loginWithKakaoTalk() async throws -> OAuthToken {
    try await withCheckedThrowingContinuation { continuation in
        UserApi.shared.loginWithKakaoTalk { oAuthToken, error in
            if let error {
                continuation.resume(throwing: error)
            } else if let oAuthToken {
                continuation.resume(returning: oAuthToken)
            } else {
                continuation.resume(throwing: KakaoLoginError.emptyData)
            }
        }
    }
}

어떤 상황인지 확인 위해 크래시 로그 기재해주시겠어요?

Thread 0 Crashed:
0   libswiftCore.dylib            	0x0000000199fb4e2c _assertionFailure(_:_:file:line:flags:) + 264 (AssertCommon.swift:147)
1   libswift_Concurrency.dylib    	0x00000001a72874a0 CheckedContinuation.resume(returning:) + 412 (CheckedContinuation.swift:169)
2   DongwonMall                   	0x00000001027dd160 closure #1 in closure #1 in KakaoLoginRepository.loginWithKakaoTalk() + 392
3   DongwonMall                   	0x00000001027dd5f0 partial apply for closure #1 in closure #1 in KakaoLoginRepository.loginWithKakaoTalk() + 68
4   ThirdPartyLibraryKit          	0x0000000103bda968 closure #1 in closure #1 in AuthController._authorizeWithTalk(launchMethod:prompts:channelPublicIds:serviceTerms:nonce:completion:) + 388
5   ThirdPartyLibraryKit          	0x0000000103bdf72c partial apply for closure #1 in closure #1 in AuthController._authorizeWithTalk(launchMethod:prompts:channelPublicIds:serviceTerms:nonce:completion:) + 16 (/<compiler-generated>:0)
6   ThirdPartyLibraryKit          	0x0000000103bd1710 closure #1 in AuthApi.token(code:codeVerifier:redirectUri:completion:) + 880 (AuthApi.swift:101)
7   ThirdPartyLibraryKit          	0x0000000103bcdc7c closure #2 in Api.responseData(_:_:parameters:headers:sessionType:apiType:logging:completion:) + 1384 (Api.swift:193)
8   ThirdPartyLibraryKit          	0x0000000103ad4af4 partial apply for specialized closure #2 in closure #2 in closure #3 in closure #1 in DownloadRequest._response<A>(queue:responseSerializer:completionHandler:) + 48
9   ThirdPartyLibraryKit          	0x0000000103a46614 thunk for @escaping @callee_guaranteed () -> () + 28 (/<compiler-generated>:0)
10  libdispatch.dylib             	0x00000001a3751248 _dispatch_call_block_and_release + 32 (init.c:1549)
11  libdispatch.dylib             	0x00000001a3752fa8 _dispatch_client_callout + 20 (object.m:576)
12  libdispatch.dylib             	0x00000001a3761a34 _dispatch_main_queue_drain + 984 (queue.c:8093)
13  libdispatch.dylib             	0x00000001a376164c _dispatch_main_queue_callback_4CF + 44 (queue.c:8253)
14  CoreFoundation                	0x000000019ba0abcc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1793)
15  CoreFoundation                	0x000000019ba071c0 __CFRunLoopRun + 1996 (CFRunLoop.c:3163)
16  CoreFoundation                	0x000000019ba59284 CFRunLoopRunSpecific + 588 (CFRunLoop.c:3434)
17  GraphicsServices              	0x00000001e8cc94c0 GSEventRunModal + 164 (GSEvent.c:2196)
18  UIKitCore                     	0x000000019e5a2674 -[UIApplication _run] + 816 (UIApplication.m:3846)
19  UIKitCore                     	0x000000019e1c8e88 UIApplicationMain + 340 (UIApplication.m:5503)
20  UIKitCore                     	0x000000019e90515c UIApplicationMain(_:_:_:_:) + 104 (UIKit.swift:565)
21  DongwonMall                   	0x0000000102674bec specialized static UIApplicationDelegate.main() + 28 (/<compiler-generated>:32)
22  DongwonMall                   	0x0000000102674bec static AppDelegate.$main() + 28 (AppDelegate.swift:0)
23  DongwonMall                   	0x0000000102674bec main + 116
24  dyld                          	0x00000001c1cb5de8 start + 2724 (dyldMain.cpp:1338)

위와 같습니다.

@이준복8743

안녕하세요. iOS SDK 담당자입니다.

현재 전달 주신 로그를 확인 했을 때, continuation.resume(returning: oAuthToken) 가 발생하기 전에 continuation.resume(:)이 일어난 것으로 보이는데요. 이 때, resume 된 값이 어떤 값인지 확인 가능할까요?

크래시 재현이 불가해서 어떤값인지 확인이 불가능합니다… 하지만 returning뿐 아니라 throwing에서도 오류가 발생하고 있습니다

0   libswiftCore.dylib            	0x0000000186d78e2c _assertionFailure(_:_:file:line:flags:) + 264 (AssertCommon.swift:147)
1   libswift_Concurrency.dylib    	0x000000019404b67c CheckedContinuation.resume(throwing:) + 472 (CheckedContinuation.swift:189)
2   DongwonMall                   	0x00000001002a9120 closure #1 in closure #1 in KakaoLoginRepository.loginWithKakaoTalk() + 328
3   DongwonMall                   	0x00000001002a95f0 partial apply for closure #1 in closure #1 in KakaoLoginRepository.loginWithKakaoTalk() + 68
4   ThirdPartyLibraryKit          	0x0000000100b3e6dc closure #1 in AuthController._authorizeWithTalk(launchMethod:prompts:channelPublicIds:serviceTerms:nonce:completion:) + 616 (AuthController.swift:130)
5   ThirdPartyLibraryKit          	0x0000000100b46474 closure #1 in static AuthController.handleOpenUrl(url:options:) + 8 (AuthController.swift:208)
6   ThirdPartyLibraryKit          	0x0000000100b46474 partial apply for closure #1 in static CertApi.handleOpenUrl(url:options:) + 52 (/<compiler-generated>:0)
7   ThirdPartyLibraryKit          	0x00000001009ae614 thunk for @escaping @callee_guaranteed () -> () + 28 (/<compiler-generated>:0)
8   libdispatch.dylib             	0x0000000190516fa8 _dispatch_client_callout + 20 (object.m:576)
9   libdispatch.dylib             	0x000000019051a45c _dispatch_continuation_pop + 596 (queue.c:325)
10  libdispatch.dylib             	0x000000019052e620 _dispatch_source_latch_and_call + 420 (source.c:596)
11  libdispatch.dylib             	0x000000019052d1e8 _dispatch_source_invoke + 836 (source.c:961)
12  libdispatch.dylib             	0x0000000190525948 _dispatch_main_queue_drain + 748 (queue.c:8093)
13  libdispatch.dylib             	0x000000019052564c _dispatch_main_queue_callback_4CF + 44 (queue.c:8253)
14  CoreFoundation                	0x00000001887cebcc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1793)
15  CoreFoundation                	0x00000001887cb1c0 __CFRunLoopRun + 1996 (CFRunLoop.c:3163)
16  CoreFoundation                	0x000000018881d284 CFRunLoopRunSpecific + 588 (CFRunLoop.c:3434)
17  GraphicsServices              	0x00000001d5a8d4c0 GSEventRunModal + 164 (GSEvent.c:2196)
18  UIKitCore                     	0x000000018b366674 -[UIApplication _run] + 816 (UIApplication.m:3846)
19  UIKitCore                     	0x000000018af8ce88 UIApplicationMain + 340 (UIApplication.m:5503)
20  UIKitCore                     	0x000000018b6c915c UIApplicationMain(_:_:_:_:) + 104 (UIKit.swift:565)
21  DongwonMall                   	0x0000000100140bec specialized static UIApplicationDelegate.main() + 28 (/<compiler-generated>:32)
22  DongwonMall                   	0x0000000100140bec static AppDelegate.$main() + 28 (AppDelegate.swift:0)
23  DongwonMall                   	0x0000000100140bec main + 116
24  dyld                          	0x00000001aea79de8 start + 2724 (dyldMain.cpp:1338)


@이준복8743

현재 해당 에러의 재현 및 원인 파악이 어려운데요.
카카오 로그인 콜백을 받았을 때, 처리하는 handleOpenUrl() 호출부와 func loginWithKakaoTalk() async throws 호출부의 구현 단을 공유해주실 수 있을까요?

개발자 문서에 나와있는 내용을 토대로 url이 들어왔을때 kakao링크라면 handleOpenUrl()에 url만 전달해주고 있습니다.
마찬가지로 loginWithKakaoTalk()는 withCheckedThrowingContinuation로만 감싸주고 있습니다.

 func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey : Any] = [:]
    ) -> Bool {
        
        ...
        // Kakao
        if AuthApi.isKakaoTalkLoginUrl(url) {
            return AuthController.handleOpenUrl(url: url)
        }
       ...
        return false
    }
@MainActor
    func loginWithKakao() async throws -> OAuthToken {
        try await UserApi.isKakaoTalkLoginAvailable() ? loginWithKakaoTalk() : loginWithKakaoAccount()
    }
    
    @MainActor
    func loginWithKakaoTalk() async throws -> OAuthToken {
        try await withCheckedThrowingContinuation { continuation in
            UserApi.shared.loginWithKakaoTalk { oAuthToken, error in
                if let error {
                    continuation.resume(throwing: error)
                } else if let oAuthToken {
                    continuation.resume(returning: oAuthToken)
                } else {
                    continuation.resume(throwing: KakaoLoginError.emptyData)
                }
            }
        }
    }
    
    @MainActor
    func loginWithKakaoAccount() async throws -> OAuthToken {
        try await withCheckedThrowingContinuation { continuation in
            UserApi.shared.loginWithKakaoAccount { oAuthToken, error in
                if let error {
                    continuation.resume(throwing: error)
                } else if let oAuthToken {
                    continuation.resume(returning: oAuthToken)
                } else {
                    continuation.resume(throwing: KakaoLoginError.emptyData)
                }
            }
        }
    }

@이준복8743

내부에서 테스트 시 이미 사용된 authorizeWithTalkCompletionHandler 가 2번 이상 불리는 경우 말씀주신 사항이 발생하는 것 확인하였습니다.

해당 부분 수정하여 배포하도록 하겠습니다.

제보 감사합니다.

cc. @tim.l @woody.ho

2개의 좋아요

도움이 되어 다행입니다 !
빠른 확인 감사합니다

안녕하세요.

해당 부분이 수정된 iOS SDK 2.24.1이 배포되었습니다.

확인 하시고 문제가 있다면 말씀 부탁드립니다.

감사합니다.

cc. @woody.ho @tim.l

1개의 좋아요