Loading UIWebView contents in AJAX blocks the main thread

I am using webview in a modal viewController that loads a page. A page may take up to 10 seconds to load content into AJAX.

If you remove the modal viewController after the page is fully loaded, everything looks good. However, if I fire the modal viewController while the page is loading, the user interface is completely blocked. I paused debugging when the user interface was blocked, this is what happens in the main thread:

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

The user interface freezes for about 10 seconds, which is the exact page load time.

I tried calling [_webview stopLoading] before rejecting the modal view controller, but that doesn't help.

- , , -?

+4
2

, CSS, . , , , UIWebView, CSS, , webView .

0

Source: https://habr.com/ru/post/1526335/


All Articles