Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS WebTryThreadLock crash

I have a crash in my app that I cannot debug for the life of me. When plugged in and debugging from Xcode on a device and NSZombieEnabled on, I do not receive the crash. When I unplug and run the app on its own, or turn of NSZombieEnabled, it crashes every time.

Here is what I get when I turn off NSZombieEnabled: EXC_BAD_ACCESS

bool _WebTryThreadLock(bool), 0x58a260: Multiple locks on web thread not allowed! Please file a bug. Crashing now...
1   _ZL17_WebTryThreadLockb
2   _ZL14WebRunLoopLockP19__CFRunLoopObservermPv
3   __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
4   __CFRunLoopDoObservers
5   __CFRunLoopRun
6   CFRunLoopRunSpecific
7   CFRunLoopRunInMode
8   _ZL12RunWebThreadPv
9   _pthread_start
10  thread_start

Here is the stack trace from the test flight:

0 App 0x001ff492 testflight_backtrace + 142
1 App 0x001fffac TFSignalHandler + 212
2 libsystem_c.dylib 0x349e9538 _sigtramp + 48
3 JavaScriptCore 0x34b66aee WTFReportBacktrace + 146
4 WebCore 0x33ed5676 _ZL14WebRunLoopLockP19__CFRunLoopObservermPv + 30
5 CoreFoundation 0x33b39b4a __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
6 CoreFoundation 0x33b37d86 __CFRunLoopDoObservers + 258
7 CoreFoundation 0x33b3804e __CFRunLoopRun + 614
8 CoreFoundation 0x33abb4dc CFRunLoopRunSpecific + 300
9 CoreFoundation 0x33abb3a4 CFRunLoopRunInMode + 104
10 WebCore 0x33f7712e _ZL12RunWebThreadPv + 402
11 libsystem_c.dylib 0x349a0c1c _pthread_start + 320
12 libsystem_c.dylib 0x349a0ad7 thread_start + 7

I have had this crash before, and I have resolved it by throwing in the line to my viewDidLoad method on one of the view controllers where the crashing was occurring:

[[NSRunLoop currentRunLoop] runUntilDate: [NSDate dateWithTimeIntervalSinceNow:0.01]];

This line is not helping now.

The process that causes the app to crash is: Present share view controller, Dismiss share view controller, Switch tab view on tabViewController, Press button which presents share2 view controller

I am not doing any background processing or changing any UI, the crash happens RIGHT when you hit the button that presents the share2 view controller. This crash was not happening a few days ago and I have tried to revert all of my changes to find the cause of the issue, but I had no luck.

I have also scoured the internet for this error, and none of the info I found has helped me.

Any advice to point me in the right direction would be greatly appreciated, thanks!

like image 603
RyanG Avatar asked Nov 14 '22 08:11

RyanG


1 Answers

The stack trace doesn't help at all, it just shows that the exception is re-thrown from another runloop. You need a crash report that also shows the last exception backtrace to get an idea from where it is coming.

Without that knowledge it is rather wild guessing: I assume the webview is still running in the background and then trying to send some data to its delegate. Did you set a delegate when in share view controller? Did you set it to nil on viewWillDisappear or viewDidDisappear?

P.S.: The NSRunLoop line you added is a ugly hack, you shouldn't do this, since it is not fixing anything for real.

P.P.S.: There are other crash reporting frameworks and services based on PLCrashReporter that provide the last exception backtrace and show the state of all threads instead only the main thread.

like image 91
Kerni Avatar answered Nov 16 '22 04:11

Kerni