iphone - 恢复 iPhone 应用程序后偶尔黑屏

标签 iphone ios testflight sdwebimage

在测试我们的 iPhone 应用程序的新版本时,我们偶尔会在 applicationWillEnterForeground 之后的某个时间恢复应用程序时看到应用程序窗口完全变黑。使应用程序再次运行的唯一方法是完全关闭它,然后重新启动应用程序。我们无法确定持续重现的步骤。这个问题似乎是随机发生的,但只有在将应用程序置于后台后返回应用程序时才会发生。有时它会在几秒钟后发生,有时它不会发生一个多星期。

以下是正常运行时主视图中的线程:

threadsDuringNormalOperation

以下是发生此问题且我暂停调试器时的线程:

threadsDuringBlackScreen

我尝试过的事情

在应用恢复时记录所有内容

当应用程序恢复时,似乎没有任何异常。此外,在按下主页按钮之前,applicationDidBecomeActive 之后我的代码都不会执行。

2013-05-15 22:22:23 AppDelegate::applicationDidBecomeActive
2013-05-15 22:22:23 self.window = <UIWindow: 0x1dd6ee80; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <UIWindowLayer: 0x1dd6ef80>>
2013-05-15 22:22:23 self.window.subviews.count = 7
2013-05-15 22:22:23 self.navigationController = <UINavigationController: 0x1dd87190>
2013-05-15 22:22:23 self.navigationController.visibleViewController = <MyViewController: 0x1dd7ffe0>
2013-05-15 22:22:23 self.navigationController.view = <UILayoutContainerView: 0x1dd876e0; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x1dd877a0>>
2013-05-15 22:22:23 self.navigationController.viewControllers.count = 1
2013-05-15 22:22:23 TestFlight: App Token is recognized
2013-05-15 22:22:24 AppDelegate::applicationWillResignActive
2013-05-15 22:22:24 TestFlight: End of Session

日志中有几项一开始让我很在意,但我在正常运行中观察到它们,所以我不再认为它们有关联。为了以防万一,它们在这里:

紧接着 ApplicationWillEnterForeground:

installd[54] <Error>: 0x2ff8d000 filter_attributes: Info.plist keys requested via MobileInstallationLookup/Browse in client Xcode (via mobile_installation_proxy) were not found in MobileInstallation's cache. Please file a bug requesting that these keys be added: <CFBasicHash 0x1cd86080 [0x3c44d100]>{type = mutable set, count = 18,
entries =>
    0 : <CFString 0x3c4399f4 [0x3c44d100]>{contents = "CFBundlePackageType"}
    1 : <CFString 0x1cebf1e0 [0x3c44d100]>{contents = "BuildMachineOSBuild"}
    2 : <CFString 0x3c43aa44 [0x3c44d100]>{contents = "CFBundleResourceSpecification"}
    3 : <CFString 0x1ce90cf0 [0x3c44d100]>{contents = "DTPlatformBuild"}
    4 : <CFString 0x3c437794 [0x3c44d100]>{contents = "DTCompiler"}
    5 : <CFString 0x3c439564 [0x3c44d100]>{contents = "CFBundleSignature"}
    6 : <CFString 0x3c43a224 [0x3c44d100]>{contents = "DTSDKName"}
    7 : <CFString 0x1cebe5f0 [0x3c44d100]>{contents = "NSBundleResolvedPath"}
    8 : <CFString 0x3c436eb4 [0x3c44d100]>{contents = "UISupportedInterfaceOrientations"}
    10 : <CFString 0x3c43ee84 [0x3c44d100]>{contents = "DTXcode"}
    13 : <CFString 0x3c43eeb4 [0x3c44d100]>{contents = "CFBundleInfoDictionaryVersion"}
    16 : <CFString 0x3c43c304 [0x3c44d100]>{contents = "CFBundleSupportedPlatforms"}
    17 : <CFString 0x1ceabd10 [0x3c44d100]>{contents = "DTXcodeBuild"}
    18 : <CFString 0x1cebb610 [0x3c44d100]>{contents = "UIStatusBarTintParameters"}
    19 : <CFString 0x3c43ae54 [0x3c44d100]>{contents = "DTPlatformVersion"}
    20 : <CFString 0x3c43dbf4 [0x3c44d100]>{contents = "DTPlatformName"}
    21 : <CFString 0x3c43ec84 [0x3c44d100]>{contents = "CFBundleDevelopmentRegion"}
    22 : <CFString 0x1ceb9ae0 [0x3c44d100]>{contents = "DTSDKBuild"}
}

不久之后:

lockdownd[45] <Notice>: 2ff24000 special_case_get: MGCopyAnswer(kMGQReleaseType) returned NULL

移除 TestFlight

这是一个通过 TestFlight 分发的版本,我们已经成功地将其用于之前的几个版本。我也在 Xcode 部署的构建中观察到这种行为,因此至少在部署方面排除了 TestFlight 作为潜在的违规者。此外,我已经从代码中删除了 TestFlight 调用并测试了应用程序。几天后,我观察到了这个问题,所以我知道它与 TestFlight 无关。

已验证所有 NSURLConnections 都是异步执行的

已验证 UI 的所有更新都在主线程上执行

此时我真正掌握的唯一信息是 main 和 UIApplicationMain 不知何故不再位于堆栈中。怎么会这样?

另外,这个应用程序使用了 SDWebImage 并且当这个问题发生时在显示的 View 中有 UIImageViews,所以可能那里有问题,但我真的怀疑这样一个被高度使用的库会有如此明显的缺陷。

最佳答案

当不允许运行主线程来刷新 UI 时,会发生这种情况。可能的原因:

  • 死锁(在我的经验中最常见)
  • 在网络连接不佳时进行同步网络调用
  • 无限循环

我建议您从检查所有使用 GCD 和其他线程机制的代码开始。

祝你好运,这些都是非常讨厌的问题。对不起,我不能更切题,因为你显示的日志没有响起。顺便说一句,您是否只在应用程序挂起时才在日志中获取这些内容?

关于iphone - 恢复 iPhone 应用程序后偶尔黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16378609/

相关文章:

ios - 如何连接自定义 UIView?

ios - 从 View 过渡 :toView:duration:options:completion: confusion

ios - 将 subview 添加到 UITableViewController

iphone - 如何配置 Xcode 项目以使用 TestFlightApp 进行 Beta 测试?

ios - TestFlight 状态已批准和准备提交之间有什么区别?

ios - 用于测试的 iTunes Connect 问题

iphone - 核心数据和 iPhone 的 NSDecimalNumber 问题

iphone - 使用 cellForRowAtIndexPath : method 修改现有的可重用单元格

iphone - NSMutableDictionary 没有正确初始化

iOS : Size classes issue