简体   繁体   English

未知原因导致CFStringAppend期间Objective-C iOS应用程序崩溃

[英]Objective-C iOS app crashes during CFStringAppend for unknown reason

In my iPhone app, for some users the app will always crash, whenever they open a certain window. 在我的iPhone应用程序中,对于某些用户,只要打开某个窗口,该应用程序将始终崩溃。 The same window works fine for me and other people, but always causes a crash for some people. 相同的窗口对我和其他人正常工作,但始终对某些人造成崩溃。 It is unclear at this moment what the difference is between people for whom it fails, and for whom it works fine. 目前尚不清楚失败的人和成功的人之间的区别。

The animation to open the specific view will run fine, but will then cause a crash immediately after the animation is finished. 用于打开特定视图的动画可以正常运行,但是在动画完成后立即将导致崩溃。

They have sent me the crashlog, but it is hard to understand what is exactly going wrong. 他们已经向我发送了崩溃日志,但是很难理解到底出了什么问题。 I am hoping you can help me understand. 我希望你能帮助我理解。 The cause for the failure as given by the crashlog is the following exception: 崩溃日志给出的失败原因是以下异常:

Last Exception Backtrace:
0   CoreFoundation                  0x1836ffd38 __exceptionPreprocess + 124
1   libobjc.A.dylib                 0x182c14528 objc_exception_throw + 55
2   CoreFoundation                  0x18370d1f8 -[NSObject+ 1372664 (NSObject) doesNotRecognizeSelector:] + 139
3   UIKit                           0x18cec7cc4 -[UIResponder doesNotRecognizeSelector:] + 295
4   CoreFoundation                  0x1837056e4 ___forwarding___ + 1379
5   CoreFoundation                  0x1835eb0dc _CF_forwarding_prep_0 + 91
6   CoreFoundation                  0x1835d6be8 CFStringAppend + 519
7   CoreFoundation                  0x1836bddf0 __CFStringAppendFormatCore + 9271
8   CoreFoundation                  0x1836bf658 _CFStringCreateWithFormatAndArgumentsAux2 + 131
9   AccessibilityUtilities          0x192d6b388 _AXStringForArgs + 279
10  UIKit                           0x1a242adf8 -[UIViewControllerAccessibility viewDidAppear:] + 267
11  UIKit                           0x18cb2869c -[UIViewController _setViewAppearState:isAnimating:] + 851
12  UIKit                           0x18cb28c08 -[UIViewController _endAppearanceTransition:] + 227
13  UIKit                           0x18cbcee00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1327
14  UIKit                           0x1a2440cd4 -[UINavigationControllerAccessibility navigationTransitionView:didEndTransition:fromView:toView:] + 111
15  UIKit                           0x18cc96bbc __49-[UINavigationController _startCustomTransition:]_block_invoke + 251
16  UIKit                           0x18cc229d8 -[_UIViewControllerTransitionContext completeTransition:] + 115
17  UIKit                           0x18cd67d30 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.124 + 751
18  UIKit                           0x18cb47d7c -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 763
19  UIKit                           0x18cb4770c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 311
20  UIKit                           0x18cb47418 -[UIViewAnimationState animationDidStop:finished:] + 295
21  UIKit                           0x1a2468970 -[UIViewAnimationStateAccessibility animationDidStop:finished:] + 131
22  QuartzCore                      0x1876ebd6c CA::Layer::run_animation_callbacks+ 1232236 (void*) + 283
23  libdispatch.dylib               0x183085048 _dispatch_client_callout + 15
24  libdispatch.dylib               0x183091b74 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1015
25  CoreFoundation                  0x1836a7f20 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
26  CoreFoundation                  0x1836a5afc __CFRunLoopRun + 2011
27  CoreFoundation                  0x1835c62d8 CFRunLoopRunSpecific + 435
28  GraphicsServices                0x185457f84 GSEventRunModal + 99
29  UIKit                           0x18cb73880 UIApplicationMain + 207
30  Flyskyhy                        0x10490bd80 main + 32128 (main.m:17)
31  libdyld.dylib                   0x1830ea56c start + 3

The crashlog seems to indicate that it goes wrong while doing a CFStringAppend , but it is not clear which string is the problem, or what is wrong with it, or even why a CFStringAppend is needed. 崩溃日志似乎表明在执行CFStringAppend ,但是不清楚是哪个字符串出了问题,或者出了什么问题,甚至还不清楚为什么需要CFStringAppend All strings visible in the view have been filled in already before the animation starts, and they all are correct. 在动画开始之前,视图中所有可见的字符串已经被填充,并且它们都是正确的。

EDIT: 编辑:

As requested, here is the code that starts the view. 根据要求,以下是启动视图的代码。 Everything is under a NavigationController, so the new view controller is pushed on the navigation stack to open it. 一切都在NavigationController下,因此将新的视图控制器推入导航堆栈中以将其打开。

WaypointEditController *controller = [[WaypointEditController alloc] initWithNibName:@"WayPointEdit" bundle:nil];
controller.navigationItem.title = @"New Waypoint";
// initialisation of other, custom, fields of controller

[self.navigationController pushViewController:controller animated:YES];

The WaypointEditController class that is pushed is derived from UIViewController . 推送的WaypointEditController类是从UIViewController派生的。 The viewWillAppear is overridden, to do initialisation of the fields of the view. 覆盖viewWillAppear ,以初始化视图的字段。 But - relevant here - viewDidAppear is not overridden. 但是-在这里相关viewDidAppear 没有被覆盖。

In case relevant, here are the most important actions in the viewWillAppear method: 如果相关,以下是viewWillAppear方法中最重要的操作:

- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];

    self.navigationItem.title = @"New Waypoint";

    // other initialisation of internal fields
}

Like you, I have customers reporting this problem and I could see the stack traces that XCode downloaded from production but I could not reproduce it... until I tried enabling "voice over". 像您一样,我有客户报告此问题,我可以看到XCode从生产中下载的堆栈跟踪,但是我无法复制它……直到尝试启用“语音结束”为止。

The other accessibility options that I tried worked OK. 我尝试的其他可访问性选项正常。

The stack trace shows that iOS is sending a selector of "length" to an instance of UILabel. 堆栈跟踪显示iOS正在向UILabel实例发送“长度”选择器。 This seemed odd. 这似乎很奇怪。 To see what would happen, I added a "length" method to UILabel to return the length of the UILabel's text property. 为了查看会发生什么,我向UILabel添加了“ length”方法以返回UILabel的text属性的长度。 Then it just failed with an unknown selector of _encodingCantBeStoredInEightBitCFString. 然后,它失败了,使用了未知的_encodingCantBeStoredInEightBitCFString选择器。 So clearly iOS thought that my UILabel was something that it wasn't. 很明显,iOS认为我的UILabel并非如此。

This ended up being because "description" was used for the name of my UILabel property/IBOutlet. 最终这是因为我的UILabel属性/ IBOutlet的名称使用了“描述”。

To fix the problem I renamed the property from "description" to something different. 为了解决此问题,我将属性从“描述”重命名为其他名称。 I suspect that my synthesized "description" getter was overriding NSObject's description method (which returns an NSString which fits the selectors which were being sent to my UILabel). 我怀疑我的合成“描述”吸气剂覆盖了NSObject的描述方法(该方法返回一个NSString,适合要发送到我的UILabel的选择器)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM