iOS 7:由于范围异常,UIWebView崩溃 [英] iOS 7: UIWebView crashes because of range exception

查看:402
本文介绍了iOS 7:由于范围异常,UIWebView崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个使用krpano查看器的应用程序,这是一个使用JavaScript构建的Panorama Viewer。我正在使用保存在iPad上的本地图像在UIWebView中加载此Panorama查看器。

I'm currently building an App that uses the krpano viewer, which is a Panorama Viewer built with JavaScript. I'm loading this Panorama viewer in a UIWebView with local images that are saved on the iPad.

但是在使用Panorama查看器一段时间之后,我收到此错误,应用程序崩溃:

But after using the Panorama viewer for a while, I get this error and the app crashes:

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

有没有人知道为什么会这样?当我在UIWebView中加载在线页面时没有问题。

Does anyone have an idea why this happens? When I load the online page in the UIWebView there is no problem.

感谢您的帮助!

推荐答案

这可能与内存有关。当Web应用程序使用Javascript分配太多内存时,会发生奇怪的事情。

This is probably a memory related issue. When a web application allocates too much memory using Javascript, weird things will happen.

您最好的选择是观察内存警告通知并尝试从外部影响Web应用程序。当然这取决于Web应用程序的细节,但您可能想尝试禁用 userInteractionEnabled 一段时间让Web视图赶上排队的用户输入操作,或者,如果内存警告仍然存在,请尝试重新加载网络视图。

Your best bet is to observe memory warning notifications and try to influence the web app from the outside. 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.

不幸的是,这里没有简单的解决方案。

Unfortunately there are no easy solutions here.

这篇关于iOS 7:由于范围异常,UIWebView崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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