Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

iphone - Tried to obtain the web lock from a thread other than the main thread or the web thread. Crashing now

bool _WebTryThreadLock(bool), 0x8053ce0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

I'm getting this error.

Today I've discovered this error for the first time, the password dialog is shown and the alertview is showing on top, which shouldn't occur till viewWillAppear when the view is shown. This all seemed to work fine when I developed this the other day. Not sure why the thread lock has been lost and how and were to implement it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
This may be a result of calling to UIKit from a secondary thread. Crashing now...

...and as far as I can see that's just what you're doing. You're calling [alertProgress dismissWithClickedButtonIndex:0 animated:YES];, a UIKit method, from a thread other than your main thread(s), which is not allowed.

For a very straight forward way to call back to the main thread if you can't use GCD, take a look at DDFoundation.

Your code would in that case only change to do;

[[alertProgress dd_invokeOnMainThread] dismissWithClickedButtonIndex:0 
                                       animated:YES]; 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...