简体   繁体   English

iOS 7:由于范围异常,UIWebView崩溃

[英]iOS 7: UIWebView crashes because of range exception

I'm currently building an App that uses the krpano viewer, which is a Panorama Viewer built with JavaScript. 我目前正在构建一个使用krpano查看器的应用程序,这是一个使用JavaScript构建的Panorama Viewer。 I'm loading this Panorama viewer in a UIWebView with local images that are saved on the iPad. 我正在UIWebView中加载此Panorama查看器,其中包含保存在iPad上的本地图像。

But after using the Panorama viewer for a while, I get this error and the app crashes: 但在使用Panorama查看器一段时间后,我收到此错误并且应用程序崩溃:

Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[WebCoreSharedBufferData getBytes:range:]: range {0, 4000} exceeds data length 0'
*** First throw call stack:
(0x2e213f53 0x38a226af 0x2e213e95 0x2eb4dc31 0x2e16ca65 0x2ef4ce47 0x2ef4cd21 0x2ef68f03 0x2ef682db 0x2ef68029 0x2ef67e61 0x2ef67dcf 0x2ef6bd39 0x2ef6b813 0x2ef5471f 0x2e29b2ed 0x30635c6d 0x30635117 0x30621069 0x30620bad 0x3061d949 0x3061c051 0x38f0c297 0x38f0c09b 0x38f0cd15 0x38f0cf8d 0x39047dbf 0x39047c84)
libc++abi.dylib: terminating with uncaught exception of type NSException

Does anyone have an idea why this happens? 有谁知道为什么会这样? When I load the online page in the UIWebView there is no problem. 当我在UIWebView中加载在线页面时没有问题。

Thanks for your help! 谢谢你的帮助!

This is probably a memory related issue. 这可能是与内存相关的问题。 When a web application allocates too much memory using Javascript, weird things will happen. 当Web应用程序使用Javascript分配太多内存时,会发生奇怪的事情。

Your best bet is to observe memory warning notifications and try to influence the web app from the outside. 您最好的选择是观察内存警告通知并尝试从外部影响Web应用程序。 Of course this depends on the specifics of the web app but you might want to try disabling userInteractionEnabled for a while to let the web view catch up with queued user input actions or, if the memory warning persists, try to reload the web view. 当然,这取决于Web应用程序的细节,但您可能希望尝试禁用userInteractionEnabled一段时间以使Web视图赶上排队的用户输入操作,或者,如果内存警告仍然存在,请尝试重新加载Web视图。

Unfortunately there are no easy solutions here. 不幸的是,这里没有简单的解决方案

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

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