【问题标题】:App got crashed when i reload the url in cocoa webview当我在 cocoa webview 中重新加载 url 时,应用程序崩溃了
【发布时间】:2015-07-09 06:36:52
【问题描述】:

在我的可可应用程序中,我使用 WebView 来加载我的 URL。根据我的要求,我将每 10 分钟重新加载一次 URL。但有时,当我尝试重新加载时,应用程序崩溃了。我正在使用下面的代码在 webview 中加载 URL。

样本.h

#import <WebKit/WebKit.h>
@property(nonatomic,retain) IBOutlet WebView *webview;

示例.m

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"www.dummyurl.com"]];
  [self->webview.mainFrame loadRequest:request];

堆栈跟踪:

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_PROTECTION_FAILURE at 0x00007fff56efeff8

VM Regions Near 0x7fff56efeff8:
    MALLOC_TINY            00007f9e7b000000-00007f9e7b100000 [ 1024K] rw-/rwx SM=ZER  
--> STACK GUARD            00007fff536ff000-00007fff56eff000 [ 56.0M] ---/rwx SM=NUL  stack guard for thread 0
    Stack                  00007fff56eff000-00007fff576ff000 [ 8192K] rw-/rwx SM=COW  thread 0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.WebCore             0x00007fff90238264 WebCore::RenderObject::containingBlock() const + 4
1   com.apple.WebCore             0x00007fff9036cdaf WebCore::RenderBlock::computeBlockPreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 63
2   com.apple.WebCore             0x00007fff90d0524a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 58
3   com.apple.WebCore             0x00007fff9047eaab WebCore::RenderBox::computeIntrinsicLogicalWidthUsing(WebCore::Length, WebCore::LayoutUnit, WebCore::LayoutUnit) const + 187
4   com.apple.WebCore             0x00007fff9033f8f4 WebCore::RenderBox::computeReplacedLogicalWidthUsing(WebCore::Length) const + 212
5   com.apple.WebCore             0x00007fff9033f707 WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(WebCore::LayoutUnit, WebCore::ShouldComputePreferred) const + 215
6   com.apple.WebCore             0x00007fff9033f572 WebCore::RenderReplaced::computeReplacedLogicalWidth(WebCore::ShouldComputePreferred) const + 1074
7   com.apple.WebCore             0x00007fff9033fcfb WebCore::RenderReplaced::computePreferredLogicalWidths() + 139
8   com.apple.WebCore             0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
9   com.apple.WebCore             0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
10  com.apple.WebCore             0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
11  com.apple.WebCore             0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
12  com.apple.WebCore             0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
13  com.apple.WebCore             0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
14  com.apple.WebCore             0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
15  com.apple.WebCore             0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
16  com.apple.WebCore             0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
17  com.apple.WebCore             0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105
18  com.apple.WebCore             0x00007fff90d0523a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 42
19  com.apple.WebCore             0x00007fff9031f6a4 WebCore::RenderBlock::computePreferredLogicalWidths() + 356
20  com.apple.WebCore             0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
21  com.apple.WebCore             0x00007fff9036d07c WebCore::RenderBlock::computeBlockPreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 780
22  com.apple.WebCore             0x00007fff90d0524a WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) const + 58
23  com.apple.WebCore             0x00007fff9047eaab WebCore::RenderBox::computeIntrinsicLogicalWidthUsing(WebCore::Length, WebCore::LayoutUnit, WebCore::LayoutUnit) const + 187
24  com.apple.WebCore             0x00007fff9033f8f4 WebCore::RenderBox::computeReplacedLogicalWidthUsing(WebCore::Length) const + 212
25  com.apple.WebCore             0x00007fff9033f707 WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(WebCore::LayoutUnit, WebCore::ShouldComputePreferred) const + 215
26  com.apple.WebCore             0x00007fff9033f572 WebCore::RenderReplaced::computeReplacedLogicalWidth(WebCore::ShouldComputePreferred) const + 1074
27  com.apple.WebCore             0x00007fff9033fcfb WebCore::RenderReplaced::computePreferredLogicalWidths() + 139
28  com.apple.WebCore             0x00007fff902c4d0b WebCore::RenderBox::minPreferredLogicalWidth() const + 27
29  com.apple.WebCore             0x00007fff90320611 WebCore::RenderBlock::computeInlinePreferredLogicalWidths(WebCore::LayoutUnit&, WebCore::LayoutUnit&) + 3105 

有人请提供解决此问题的解决方案吗?

PS:我在我的项目中使用 ARC。

【问题讨论】:

    标签: objective-c cocoa webview


    【解决方案1】:

    我建议您设置异常断点来查找代码的确切问题,但我希望您的问题是已发布对象 我认为你的 UIWebView 或 Url 变成了 nil。 请为您的对象使用强大的属性。 你能展示一些你的代码吗? 你使用自定义 webview 还是自定义 webkit ?

    【讨论】:

    • 不,我没有使用自定义框架/webview。我正在使用本机 webkit 框架和 webview。请检查我更新的代码。而且从我的角度来看,我将为 Web 视图对象使用强大的属性。我会在这里检查和更新。
    • 我接受了为我的 Web 视图对象建议强属性的答案。谢谢。
    猜你喜欢
    • 2019-06-11
    • 2020-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 2014-07-24
    • 2013-11-05
    相关资源
    最近更新 更多