Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

walty

macrumors member
Original poster
Jul 15, 2008
33
0
Hi All,

Currently trying to load a UIWebView in a separate view, and from time to time (but not always), the program crashes with the following error:

HandleDelegateSource: Unable to acquire web lock before dispatching delegate message. Please file a bug. Crashing now...

But the problem does not appear when I run the program on device. And it seems there is no corresponding record in Google (one actually, but no solution mentioned).

For safety caution, I already set the max concurrent operation to be 1, and the main UI thread would not load any other webview.

Any hint please?

Thanks.
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
The UI isn't reentrant, you can only call, modify or load the UI from your main thread. You can preload data into a non-UI object in a separate thread, if needed.

.
 

walty

macrumors member
Original poster
Jul 15, 2008
33
0
The UI isn't reentrant, you can only call, modify or load the UI from your main thread. You can preload data into a non-UI object in a separate thread, if needed.

.


Thanks for reply firewood, but I am still a bit confused, if I prefetch the data using a separate thread, how am I going to collect the data from the main UI thread, should I use a timer-like thing or an asynchronous call? In either case, I thought a separate thread should still be created (either explicitly or implicitly) to update the UI.

If the main thread just waits the separate thread to finish prefetching thread, the UI would still be hanged anyway, I guess?


Actually, I found more and more mysterious issues when trying to update UI in separate thread, and still this issue seems to occur only on simulator, and never reproduced on the device... Just not sure if this is an issue of simulator, or a hidden huge bug in my program.. :confused:
 

walty

macrumors member
Original poster
Jul 15, 2008
33
0
Ok, I got it, the key is:

Code:
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait

Now, most of the mysterious issues gone, thx a lot :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.