Deadlock on UIWebView initWithFrame

Hi,


The watchdog kills my app sometimes when I instanciate a UIWebView. This seems to be due to a deadlock (or maybe not "dead" but too long for the watchdog) caused by a lock in UIWebView's private init code.


Here is the stack trace:


libsystem_kernel.dylib 0x000000018cda1e64 __psynch_mutexwait + 8
libsystem_pthread.dylib 0x000000018ce6bfa8 _pthread_mutex_lock_slow + 292
WebCore 0x000000019285e8d8 _WebTryThreadLock(bool) + 48
WebCore 0x000000019285eec4 WebThreadLock + 104
UIKit 0x00000001940e07e0 -[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:] + 124
UIKit 0x0000000193e47b1c -[UIWebView initWithFrame:] + 72


And the watchdog error (after the 15s threshold):


*** Terminating app due to uncaught exception 'BITCrashWatchdogMainThreadException', reason: 'The main thread was blocked for too long. Deadlock?'


Some more information:


- I create all my UIWebView in the main thread.

- I sometime create a lot of UIWebViews

- I sometime load big UIWebViews.


Do you have any idea why the UIWebView would lock here?


EDIT:


After digging a bit more, it sounds like there's always another thread churning in Javascript/WebCore land after calling `JSEventListener::handleEvent()` in response to an `ImageLoader` completing. It's possible that some images are loaded in the webviews. Could there be some kind of concurrency issue?

Replies

I have same question,how did you solve it?

thanks!