【发布时间】:2023-03-31 12:48:01
【问题描述】:
我在加载页面的模式 viewController 中使用 webview。该页面最多可能需要 10 秒才能在 AJAX 中加载其内容。
如果在页面完全加载后关闭模态视图控制器,一切看起来都很好。但是,如果我在页面加载时关闭模式 viewController,则 UI 将完全锁定。当 UI 被锁定时,我暂停了调试,这是主线程中发生的事情:
Thread 1, Queue : com.apple.main-thread
#0 0x390b6fa8 in __psynch_mutexwait ()
#1 0x3911bf50 in _pthread_mutex_lock ()
#2 0x366ac60c in _WebTryThreadLock(bool) ()
#3 0x366ad434 in WebThreadLock ()
#4 0x31151cf8 in -[UIWebView dealloc] ()
#5 0x30f2f9b2 in -[UIView dealloc] ()
#6 0x30f2f9b2 in -[UIView dealloc] ()
#7 0x38b04022 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#8 0x2e6de1c8 in _CFAutoreleasePoolPop ()
#9 0x2e773e82 in __CFRunLoopRun ()
#10 0x2e6de470 in CFRunLoopRunSpecific ()
#11 0x2e6de252 in CFRunLoopRunInMode ()
#12 0x334182ea in GSEventRunModal ()
#13 0x30f93844 in UIApplicationMain ()
#14 0x00017074 in main at /Users/.../main.m:16
UI 冻结大约 10 秒,这是页面需要加载的确切时间。
我在关闭模态视图控制器之前尝试调用 [_webview stopLoading] 但它没有帮助。
有谁知道这里发生了什么以及我应该做些什么来防止 webview 冻结 UI?谢谢
【问题讨论】:
-
有同样的问题。似乎也无法弄清楚。
标签: ios objective-c uiwebview