我们在GoogleSignIn iOS框架v4.0.1中遇到this crash(通过CocoaPods链接)。
Fatal Exception: UIApplicationInvalidInterfaceOrientation
preferredInterfaceOrientationForPresentation '(7)' must match a supported interface orientation: 'portrait, landscapeLeft, landscapeRight, portraitUpsideDown'!
Fatal Exception: UIApplicationInvalidInterfaceOrientation
0 CoreFoundation 0x184656fe0 __exceptionPreprocess
1 libobjc.A.dylib 0x1830b8538 objc_exception_throw
2 CoreFoundation 0x184656f28 -[NSException initWithCoder:]
3 UIKit 0x18a87cbbc -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:]
4 UIKit 0x18b159cf0 -[_UIFullscreenPresentationController _adjustOrientationIfNecessaryInWindow:forViewController:preservingViewController:]
5 UIKit 0x18aad6d3c -[UIPresentationController _dismissWithAnimationController:interactionController:target:didEndSelector:]
6 UIKit 0x18aafd53c -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
7 UIKit 0x18a8b2848 -[UIViewController _dismissViewControllerWithTransition:from:completion:]
8 UIKit 0x18a85a6dc -[UIViewController dismissViewControllerWithTransition:completion:]
9 UIKit 0x18a85a4bc -[UIViewController dismissViewControllerWithTransition:completion:]
10 UIKit 0x18aafc7e4 -[UIViewController _performCoordinatedPresentOrDismiss:animated:]
11 UIKit 0x18a85a230 -[UIViewController dismissViewControllerAnimated:completion:]
12 Remind101 0x10069f6a0 -[GIDSignIn dismissViewController:]
13 Remind101 0x100699c4c -[GIDSignIn handleURL:fromGoogleSSOApp:]
14 Remind101 0x100699b60 -[GIDSignIn handleURL:sourceApplication:annotation:]
15 Remind101 0x1001a7398 -[RDAppDelegate application:openURL:options:] (RDAppDelegate.m:495)
16 UIKit 0x18aa13c28 __45-[UIApplication _applicationOpenURL:payload:]_block_invoke
17 UIKit 0x18aa136b0 -[UIApplication _applicationOpenURL:payload:]
18 SafariServices 0x19307a628 -[SFSafariViewController remoteViewController:hostApplicationOpenURL:]
19 SafariServices 0x193072038 -[SFBrowserRemoteViewController willOpenURLInHostApplication:]
20 CoreFoundation 0x18465ce80 __invoking___
21 CoreFoundation 0x1845522c4 -[NSInvocation invoke]
22 FrontBoardServices 0x186200884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
23 FrontBoardServices 0x1862006f0 -[FBSSerialQueue _performNext]
24 FrontBoardServices 0x186200aa0 -[FBSSerialQueue _performNextFromRunLoopSource]
25 CoreFoundation 0x18460542c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
26 CoreFoundation 0x184604d9c __CFRunLoopDoSources0
27 CoreFoundation 0x1846029a8 __CFRunLoopRun
28 CoreFoundation 0x184532da4 CFRunLoopRunSpecific
29 GraphicsServices 0x185f9d074 GSEventRunModal
30 UIKit 0x18a7edc9c UIApplicationMain
31 Remind101 0x10015b958 main (main.m:16)
32 libdyld.dylib 0x18354159c start
我们的app委托方法(堆栈跟踪中的第15帧)实现如下:
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
NSString *sourceApplication = options[UIApplicationOpenURLOptionsSourceApplicationKey];
NSString *annotation = options[UIApplicationOpenURLOptionsAnnotationKey];
// ... bunch of app-specific checks
return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
我们的崩溃日志记录显示正在打开的URL看起来像这样(模糊不清,因为我不知道数字或uid是否可以以任何方式识别):
openURL:com.googleusercontent.apps.(number)-(uid):/oauth2callback?code=4/-(uid)# sourceApplication:com.apple.SafariViewService annotation:(null)
在过去的7天里,我们收到了近300起这些崩溃事件。崩溃从8月14日开始(17日出现)并出现在该日期之前发布的版本上,所以我不相信这是我们通过我们的应用程序引入的任何内容。任何帮助表示赞赏。
答案 0 :(得分:1)
在堆栈跟踪中,GoogleSignIn解散SFSafariViewerController后发生崩溃。之前的UIViewController(不是GoogleSignIn的一部分)再次暴露,但它为preferredInterfaceOrientationForPresentation返回一个无法识别的值(7)。请注意,如果该UIViewController是您的第一个屏幕,则可能不会在其初始外观中调用其preferredInterfaceOrientationForPresentation,而是使用plist中的UISupportedInterfaceOrientations值。因此,您可能在不知情的情况下从UIViewController返回了错误的UIInterfaceOrientation,直到用户使用Google登录后再次显示该视图,从而导致崩溃。