Dead lock in WebCore/WebThreadLock
| Originator: | plu | ||
| Number: | rdar://31955525 | Date Originated: | 2017-05-03 |
| Status: | Open | Resolved: | |
| Product: | WebKit on iOS | Product Version: | iOS 10.3 |
| Classification: | Reproducible: | Always |
Area:
WebKit
Summary:
When UIWebView is executing some JavaScript it can run in a dead lock on the main thread, causing the whole application to hang. In the real world this is caused by some CPU intensive JavaScript. In the attached example project a simple while (true) { ... } loop in JavaScript is used to demonstrate the issue.
Steps to Reproduce:
1. Open attached project in Xcode 8.3.2
2. Run it on iPhone 7 10.3 Simulator
3. Tap on the "Open WebView" button
4. Wait 10 seconds
5. Tap on the back button
6. Wait 10 seconds
7. Tap again on the "Open WebView" button
Expected Results:
Open the WebView a second time.
Actual Results:
It does not open the WebView a second time. Instead the application hangs and is unresponsive.
You can pause the application at this point and get a stack trace of the main thread:
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x0000000107ba0c22 libsystem_kernel.dylib`__psynch_mutexwait + 10
frame #1: 0x0000000107bd5e6e libsystem_pthread.dylib`_pthread_mutex_lock_wait + 100
frame #2: 0x0000000107bd358d libsystem_pthread.dylib`_pthread_mutex_lock_slow + 285
frame #3: 0x000000010af466d2 WebCore`_WebTryThreadLock(bool) + 34
frame #4: 0x000000010af47508 WebCore`WebThreadLock + 88
frame #5: 0x00000001043fb58a UIKit`-[UIWebDocumentView viewportHandler:didChangeViewportSize:] + 56
frame #6: 0x000000010444c083 UIKit`-[_UIWebViewportHandler update:] + 394
frame #7: 0x00000001043fd991 UIKit`-[UIWebDocumentView setMinimumSize:updateCurrentViewportConfigurationSize:] + 105
frame #8: 0x0000000104446133 UIKit`-[UIWebView _updateViewSettings] + 723
frame #9: 0x0000000104445a9b UIKit`-[_UIWebViewScrollView setContentInset:] + 241
frame #10: 0x000000010425c644 UIKit`-[UIViewController _setNavigationControllerContentInsetAdjustment:] + 573
frame #11: 0x00000001042a1450 UIKit`-[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 804
frame #12: 0x0000000104296f84 UIKit`__49-[UINavigationController _startCustomTransition:]_block_invoke + 246
frame #13: 0x0000000104bf1dac UIKit`-[_UIViewControllerTransitionContext completeTransition:] + 102
frame #14: 0x00000001040ab360 UIKit`__53-[_UINavigationParallaxTransition animateTransition:]_block_invoke.99 + 803
frame #15: 0x000000010417bcd4 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 527
frame #16: 0x000000010414ef07 UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 222
frame #17: 0x000000010414f446 UIKit`-[UIViewAnimationState animationDidStop:finished:] + 136
frame #18: 0x00000001096af68e QuartzCore`CA::Layer::run_animation_callbacks(void*) + 306
frame #19: 0x000000010784305c libdispatch.dylib`_dispatch_client_callout + 8
frame #20: 0x000000010782440b libdispatch.dylib`_dispatch_main_queue_callback_4CF + 411
frame #21: 0x00000001069a0909 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #22: 0x0000000106966ae4 CoreFoundation`__CFRunLoopRun + 2164
frame #23: 0x0000000106966016 CoreFoundation`CFRunLoopRunSpecific + 406
frame #24: 0x00000001087f5a24 GraphicsServices`GSEventRunModal + 62
frame #25: 0x00000001040c30d4 UIKit`UIApplicationMain + 159
frame #26: 0x000000010361e1a7 WebThreadDeadLock`main at AppDelegate.swift:12
frame #27: 0x000000010788f65d libdyld.dylib`start + 1
frame #28: 0x000000010788f65d libdyld.dylib`start + 1
Version:
Xcode 8.3.2, Mac OS 10.12.4
Notes:
Configuration:
iPhone 7 Simulator, iOS 10.3
Attachments:
'WebThreadDeadLock-master.zip' was successfully uploaded.
(see here: https://github.com/technology-ebay-de/WebThreadDeadLock)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!