如果用户应答传入的iMessage,WKWebView崩溃 [英] WKWebView crashes if user answers an incoming iMessage

查看:95
本文介绍了如果用户应答传入的iMessage,WKWebView崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用崩溃严重-

CALayer position contains NaN: [377.833 nan] 

具有以下堆栈-

Fatal Exception: CALayerInvalidGeometry
0  CoreFoundation                 0x18283afe0 __exceptionPreprocess
1  libobjc.A.dylib                0x18129c538 objc_exception_throw
2  CoreFoundation                 0x18283af28 -[NSException initWithCoder:]
3  QuartzCore                     0x185b50acc CA::Layer::set_position(CA::Vec2<double> const&, bool)
4  QuartzCore                     0x185b50c48 -[CALayer setPosition:]
5  QuartzCore                     0x185b51198 -[CALayer setFrame:]
6  UIKit                          0x1889657a8 -[UIView(Geometry) setFrame:]
7  UIKit                          0x188979364 -[UIImageView _setViewGeometry:forMetric:]
8  UIKit                          0x1889c6c38 -[UIScrollView _adjustScrollerIndicators:alwaysShowingThem:]
9  UIKit                          0x188abfb34 -[UIScrollView(UIScrollViewInternal) _adjustForAutomaticKeyboardInfo:animated:lastAdjustment:]
10 WebKit                         0x18c14af3c -[WKWebView _keyboardChangedWithInfo:adjustScrollView:]
11 CoreFoundation                 0x1827d55f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
12 CoreFoundation                 0x1827d4d08 _CFXRegistrationPost
13 CoreFoundation                 0x1827d4a84 ___CFXNotificationPost_block_invoke
14 CoreFoundation                 0x1828437a8 -[_CFXNotificationRegistrar find:object:observer:enumerator:]
15 CoreFoundation                 0x18271895c _CFXNotificationPost
16 Foundation                     0x18322a930 -[NSNotificationCenter postNotificationName:object:userInfo:]
17 UIKit                          0x1893500e4 -[UIInputWindowController postStartNotifications:withInfo:]
18 UIKit                          0x189352350 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.907
19 UIKit                          0x188a383cc -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:]
20 UIKit                          0x189351dc8 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]
21 UIKit                          0x1893588b0 -[UIInputWindowController setInputViewSet:]
22 UIKit                          0x189351494 -[UIInputWindowController performOperations:withAnimationStyle:]
23 UIKit                          0x188a30d94 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:]
24 UIKit                          0x1890f7160 -[_UIRemoteKeyboards keyboardChanged:shouldConsiderSnapshottingKeyboard:isLocalEvent:]
25 UIKit                          0x1890f6e8c __37-[_UIRemoteKeyboards

在查看用户日志时,我发现了一些常见的东西-

Looking at the logs of the users I found few common things -

  1. 所有用户都在包含WKWebView的视图控制器中
  2. 所有日志都指出该应用在崩溃前已获得"applicationWillResignActive"
  3. 堆栈显示已打开键盘,但是我们没有必要在该View Controller上打开键盘
  4. 所有用户均为iOS 10.3 +

唯一合适的方案是,当应用程序带有可见的WKWebView时,用户获得了一条iMessage消息,并强行触摸它以快速找到答案.我们测试了这种情况,然后使应用崩溃了.

The only scenario that fit was that a user got an iMessage while the app was with a visible WKWebView and force touched it to a quick answer. We tested this scenario and BOOOM the app crashed.

因此我们找到了崩溃,但我们不知道发生了什么.任何人都遇到过这个问题,或者知道这可能是什么?

So we found the crash, but we do not have a clue what is going on. Any one faced that issue or has an idea what could it be?

谢谢

推荐答案

(1)首先,请仔细检查您的布局是否正确,使用自动布局"并确保您的约束是正确的,并且您正在设置正确的子视图.

(1) First Double check your layout is correct, use "Autolayout" and make sure your constraints are correct and you are setting the subviews correct.

尝试以视觉方式调试布局,以查看是否发生任何奇怪的事情.

Try to visually debug the layout to see if there are any strange things happening.

Debug-> View Debugging-> Capture View Hierarchy.

Debug->View Debugging->Capture View Hierarchy.

(2)从堆栈跟踪中我注意到键盘已经出现,因此,需要调整视图以放置键盘.值得注意的是,一旦消息到达堆栈跟踪,就会发生这种情况.

(2) From the stack trace I notice that the keyboard gets presented, and because of this, the views need to be adjusted to make place for the keyboard. It is noticeable this happens as soon as an message arrives in the stack trace.

我也可能会尝试在您的AppDelegate中辞职FirstResponder

I would also attempt to resignFirstResponder, maybe in your AppDelegate

- (void)applicationWillResignActive:(UIApplication *)application {
   [_wkWebView resignFirstResponder];
}

(3)我还发现存在一个错误,该错误中WKWEbView不会resignFirstResponder ..可能与之相关:

(3) I have also found that there is a bug, where the WKWEbView will not resignFirstResponder.. this might be related:

错误167898-当发生非编程的第一响应者更改时,不会调用[iOS]-[WKWebView成为FirstResponder]和-[WKWebView resignFirstResponder]

Bug 167898 - [iOS] -[WKWebView becomeFirstResponder] and -[WKWebView resignFirstResponder] don’t get called when non-programmatic first responder changes happen

那么可能的解决方法是,在您的申请将辞职.

Maybe a workaround then would be to present another view as soon as your application will resign.

- (void)applicationWillResignActive:(UIApplication *)application {
    // if _wkWebView is showing then hide and show other view
}

这篇关于如果用户应答传入的iMessage,WKWebView崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆