当我使用UIWebView时,主线程被阻止

时间:2017-04-17 10:48:54

标签: ios objective-c iphone uiwebview pthreads

今天我发现我的应用程序中有一个与UIWebView有关的错误,有两种情况,我请求的网址是https://estore-cn.pandora.net/Bracelets-1/

当我使用UIWebView显示网页时,我退出该页面,调用了webView的dealloc,但是UI线程被阻止了,几分钟后它就恢复了。

这是我在Xcode中按pause program execution按钮时的线程堆栈。

* thread #1: tid = 0x580710, 0x0000000180da3f6c libsystem_kernel.dylib`__psynch_mutexwait + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP * frame #0: 0x0000000180da3f6c libsystem_kernel.dylib`__psynch_mutexwait + 8 frame #1: 0x0000000180e7239c libsystem_pthread.dylib`_pthread_mutex_lock_wait + 96 frame #2: 0x0000000180e7257c libsystem_pthread.dylib`_pthread_mutex_lock_slow + 296 frame #3: 0x00000001850dc3b0 WebCore`_WebTryThreadLock(bool) + 52 frame #4: 0x00000001850dcb3c WebCore`WebThreadLock + 108 frame #5: 0x00000001865abfc0 UIKit`-[UIWebView dealloc] + 36 frame #6: 0x000000010032ba64 QDaily`-[QDWebView dealloc](self=0x00000001575f3980, _cmd="dealloc") + 148 at QDWebView.m:63 frame #7: 0x0000000180889ae8 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 508 frame #8: 0x00000001810e89fc CoreFoundation`_CFAutoreleasePoolPop + 28 frame #9: 0x00000001811bebc0 CoreFoundation`__CFRunLoopRun + 1636 frame #10: 0x00000001810e8c50 CoreFoundation`CFRunLoopRunSpecific + 384 frame #11: 0x00000001829d0088 GraphicsServices`GSEventRunModal + 180 frame #12: 0x00000001863d6088 UIKit`UIApplicationMain + 204 frame #13: 0x000000010037490c QDaily`main(argc=1, argv=0x000000016fd03af0) + 172 at main.m:16 frame #14: 0x0000000180c868b8 libdyld.dylib`start + 4

  • 第二种情况是,当我开始跳到webView页面时,发生了同样的情况。

thread #1: tid = 0x5801dc, 0x0000000180da3f6c libsystem_kernel.dylib`__psynch_mutexwait + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame #0: 0x0000000180da3f6c libsystem_kernel.dylib`__psynch_mutexwait + 8 frame #1: 0x0000000180e7239c libsystem_pthread.dylib`_pthread_mutex_lock_wait + 96 frame #2: 0x0000000180e7257c libsystem_pthread.dylib`_pthread_mutex_lock_slow + 296 frame #3: 0x00000001850dc3b0 WebCore`_WebTryThreadLock(bool) + 52 frame #4: 0x00000001850dcb3c WebCore`WebThreadLock + 108 frame #5: 0x00000001867f3dc4 UIKit`-[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:] + 128 frame #6: 0x00000001865a83ec UIKit`-[UIWebView initWithFrame:] + 80 frame #7: 0x00000001002abb60 QDaily`-[QDWebView initWithFrame:](self=0x0000000000000000, _cmd="initWithFrame:", frame=(origin = (x = 0, y = 20), size = (width = 414, height = 666))) + 120 at QDWebView.m:71 frame #8: 0x0000000100212244 QDaily`-[QDSimpleWebViewController viewDidLoad](self=0x0000000131225070, _cmd="viewDidLoad") + 796 at QDSimpleWebViewController.m:57 frame #9: 0x000000018636cc40 UIKit`-[UIViewController loadViewIfRequired] + 996 frame #10: 0x00000001863850d0 UIKit`-[UIViewController __viewWillAppear:] + 132 frame #11: 0x000000018651fe5c UIKit`-[UINavigationController _startCustomTransition:] + 1052 frame #12: 0x000000018642be40 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 688 frame #13: 0x000000018642bb1c UIKit`-[UINavigationController __viewWillLayoutSubviews] + 60 frame #14: 0x000000018642ba84 UIKit`-[UILayoutContainerView layoutSubviews] + 208 frame #15: 0x00000001863681e4 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656 frame #16: 0x0000000183cf698c QuartzCore`-[CALayer layoutSublayers] + 148 frame #17: 0x0000000183cf15c8 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 292 frame #18: 0x0000000183cf1488 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32 frame #19: 0x0000000183cf0ab8 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 252 frame #20: 0x0000000183cf0818 QuartzCore`CA::Transaction::commit() + 500 frame #21: 0x000000018636aff4 UIKit`_UIApplicationHandleEventQueue + 4980 frame #22: 0x00000001811c109c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 frame #23: 0x00000001811c0b30 CoreFoundation`__CFRunLoopDoSources0 + 540 frame #24: 0x00000001811be830 CoreFoundation`__CFRunLoopRun + 724 frame #25: 0x00000001810e8c50 CoreFoundation`CFRunLoopRunSpecific + 384 frame #26: 0x00000001829d0088 GraphicsServices`GSEventRunModal + 180 frame #27: 0x00000001863d6088 UIKit`UIApplicationMain + 204 frame #28: 0x00000001002f490c QDaily`main(argc=1, argv=0x000000016fd83af0) + 172 at main.m:16 frame #29: 0x0000000180c868b8 libdyld.dylib`start + 4

我不知道如何解决它

ADD:这是发生死锁时的webThread

* thread #19: tid = 0x58076c, 0x00000001854180f0 WebCore`WTF::HashMap<unsigned long, WTF::RefPtr<WebCore::ResourceLoader>, WTF::IntHash<unsigned long>, WTF::HashTraits<unsigned long>, WTF::HashTraits<WTF::RefPtr<WebCore::ResourceLoader> > >::remove(unsigned long const&) + 164, name = 'WebThread' * frame #0: 0x00000001854180f0 WebCore`WTF::HashMap<unsigned long, WTF::RefPtr<WebCore::ResourceLoader>, WTF::IntHash<unsigned long>, WTF::HashTraits<unsigned long>, WTF::HashTraits<WTF::RefPtr<WebCore::ResourceLoader> > >::remove(unsigned long const&) + 164 frame #1: 0x0000000185126e54 WebCore`WebCore::DocumentLoader::removeSubresourceLoader(WebCore::ResourceLoader*) + 40 frame #2: 0x00000001851292a0 WebCore`WebCore::ResourceLoader::cancel(WebCore::ResourceError const&) + 492 frame #3: 0x0000000185087764 WebCore`WebCore::ResourceLoader::init(WebCore::ResourceRequest const&) + 404 frame #4: 0x00000001850873fc WebCore`WebCore::SubresourceLoader::startLoading() + 36 frame #5: 0x000000018508735c WebCore`WebCore::ResourceLoadScheduler::servePendingRequests(WebCore::ResourceLoadScheduler::HostInformation*, WebCore::ResourceLoadPriority) + 516 frame #6: 0x00000001851070b8 WebCore`WebCore::ResourceLoadScheduler::servePendingRequests(WebCore::ResourceLoadPriority) + 412 frame #7: 0x0000000185079f1c WebCore`WebCore::ThreadTimers::sharedTimerFiredInternal() + 148 frame #8: 0x0000000185079e5c WebCore`WebCore::timerFired(__CFRunLoopTimer*, void*) + 36 frame #9: 0x00000001811c1794 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28 frame #10: 0x00000001811c1438 CoreFoundation`__CFRunLoopDoTimer + 884 frame #11: 0x00000001811beb4c CoreFoundation`__CFRunLoopRun + 1520 frame #12: 0x00000001810e8c50 CoreFoundation`CFRunLoopRunSpecific + 384 frame #13: 0x00000001850da108 WebCore`RunWebThread(void*) + 456 frame #14: 0x0000000180e6fb28 libsystem_pthread.dylib`_pthread_body + 156 frame #15: 0x0000000180e6fa8c libsystem_pthread.dylib`_pthread_start + 156 frame #16: 0x0000000180e6d028 libsystem_pthread.dylib`thread_start + 4

ADD:JavaScriptCore ::标记线程 * thread #20: tid = 0x58076d, 0x0000000180da3f24 libsystem_kernel.dylib`__psynch_cvwait + 8, name = 'JavaScriptCore::Marking' * frame #0: 0x0000000180da3f24 libsystem_kernel.dylib`__psynch_cvwait + 8 frame #1: 0x0000000180e6ece8 libsystem_pthread.dylib`_pthread_cond_wait + 648 frame #2: 0x00000001807fb42c libc++.1.dylib`std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) + 56 frame #3: 0x0000000184bc0d5c JavaScriptCore`JSC::GCThread::waitForNextPhase() + 144 frame #4: 0x0000000184bc0df4 JavaScriptCore`JSC::GCThread::gcThreadMain() + 84 frame #5: 0x0000000184896614 JavaScriptCore`WTF::threadEntryPoint(void*) + 212 frame #6: 0x0000000184896524 JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 24 frame #7: 0x0000000180e6fb28 libsystem_pthread.dylib`_pthread_body + 156 frame #8: 0x0000000180e6fa8c libsystem_pthread.dylib`_pthread_start + 156 frame #9: 0x0000000180e6d028 libsystem_pthread.dylib`thread_start + 4

0 个答案:

没有答案