简体   繁体   English

React Native iOS 8.1应用程序在访问新视图时崩溃 - 仅在不使用调试器时

[英]React Native iOS 8.1 app crashes when accessing a new view - ONLY when NOT using debugger

I have a react-native app running on iOS. 我有一个在iOS上运行的react-native应用程序。 On iOS 9.2, the app runs perfectly fine, both when using the Chrome debugger and not using it. 在iOS 9.2上,应用程序运行完全正常,无论是在使用Chrome调试器还是不使用它时。 However, in iOS 8.1, the app will load, and lists can be swiped, data is loaded from the server, etc. This is tested and works in both the simulator and on physical devices, for both OS's. 但是,在iOS 8.1中,应用程序将加载,并且可以刷新列表,从服务器加载数据等。这在两个操作系统中都经过测试,可在模拟器和物理设备上运行。

The tricky part is, when running with the Chrome debugger, iOS 8.1. 当使用Chrome调试器iOS 8.1时,棘手的部分是。 works as expected. 按预期工作。 When it is NOT running with the Chrome debugger, the app crashes whenever navigating to a new view. 当它未与Chrome调试器一起运行时,只要导航到新视图,应用程序就会崩溃。 I have a custom swipe view, so I can swipe to another view, and I can see all the content properly loaded right before it 'settles' and crashes. 我有一个自定义滑动视图,因此我可以滑动到另一个视图,我可以看到所有内容正确加载到“安定”和崩溃之前。 If I simply try to click to a new page, it will crash almost instantly. 如果我只是尝试点击一个新页面,它几乎会立即崩溃。

My guess (educated from this stackoverflow question ), is that it is a timing issue, provided that my hypothesis that iOS 8.1 runs faster than iOS 9.2 is correct. 我的猜测( 受此stackoverflow问题的教育)是,它是一个时间问题,只要我的假设iOS 8.1运行速度比iOS 9.2更正确。 I am guessing that the debugger slows down the app enough that the timing issue doesn't present itself. 我猜测调试器会减慢应用程序的速度,以至于计时问题本身并不存在。 That being said, I tried the 'slow animation' mode in the simulator, and it still crashed when not using the debugger. 话虽这么说,我在模拟器中尝试了“慢动画”模式,并且在不使用调试器时仍然崩溃。

With that in mind, I recognize it could very well be a configuration issue. 考虑到这一点,我认识到它很可能是一个配置问题。 I'm running XCode 7.2, and am using react-native 0.21.0-rc. 我正在运行XCode 7.2,并且正在使用react-native 0.21.0-rc。

The error that I get when trying to click anywhere/change views is: 尝试单击任意位置/更改视图时出现的错误是:

null is not an object (evaluating 'inst.componentWillReceiveProps')

Had this same issue on release of our app - it wouldn't show up in the simulator, only in release. 在发布我们的应用程序时遇到同样的问题 - 它不会出现在模拟器中,只会在发布时出现。

In our case, it turned out we had an error in a section of code that was only hit if the browser had gained support for the js function 在我们的例子中,事实证明我们在代码段中出现了错误,只有在浏览器获得对js函数的支持时才会出现错误

Date().toLocaleTimeString

Mozilla stated you could check for the browser support for this function by doing the following: Mozilla表示,您可以通过执行以下操作来检查浏览器对此功能的支持:

function toLocaleTimeStringSupportsLocales() {
  try {
    new Date().toLocaleTimeString('i');
  } catch (e) {
    return e​.name === 'RangeError';
  }
  return false;
}

I had not updated to the latest Xcode yet, but it was crashing on my iPhone running iOS 10. Once I upgraded Xcode to the latest version, the error began showing up in the Simulator as well, as Safari presumably gained the support for toLocaleTimeString in the sim as well. 我还没有更新到最新的Xcode,但它在运行iOS 10的iPhone上崩溃。一旦我将Xcode升级到最新版本,错误也开始出现在模拟器中,因为Safari可能获得了对toLocaleTimeString的支持。 SIM也是。 The error reported running debug was far more specific and pointed me to the fix. 报告运行调试的错误更具体,并指出我的修复。

I doubt this is the same issue, but this is how I fixed this error in my application, and how it only showed up in release versus the sim -- strictly because of differing execution paths due to different versions of Safari. 我怀疑这是同一个问题,但这就是我在我的应用程序中修复此错误的方式,以及它如何仅在版本中出现而不是sim - 严格因为不同版本的Safari导致不同的执行路径。 Hope this helps someone else with this issue. 希望这可以帮助其他人解决这个问题。

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

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