| Summary: | [iOS] allocate volume view on the main thread | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Eric Carlson <eric.carlson> | ||||
| Component: | Media | Assignee: | Eric Carlson <eric.carlson> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | commit-queue, danielo, danny.zlobinsky, glenn, icloutier, jer.noble, philipj, sergio | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=142970 | ||||||
| Attachments: |
|
||||||
|
Description
Eric Carlson
2014-11-21 10:38:37 PST
Created attachment 242053 [details]
Proposed patch.
Comment on attachment 242053 [details] Proposed patch. Clearing flags on attachment: 242053 Committed r176471: <http://trac.webkit.org/changeset/176471> All reviewed patches have been landed. Closing bug. *** Bug 138961 has been marked as a duplicate of this bug. *** This fix is not good. It deadlocks the app if the main thread is doing something related to the web view, because at the time of .
We're getting this freeze quite often, and get different stacks in the main thread, ending with:
thread #1: tid = 0x10919d, 0x33473ba8 libsystem_kernel.dylib`__psynch_mutexwait + 24, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x33473ba8 libsystem_kernel.dylib`__psynch_mutexwait + 24
frame #1: 0x334f103a libsystem_pthread.dylib`_pthread_mutex_lock + 394
frame #2: 0x307fdf20 WebCore`_WebTryThreadLock(bool) + 44
frame #3: 0x307fe736 WebCore`WebThreadLock + 82
While the WebThread will wait on dispatch_sync(dispatch_get_main_queue(), ...). The web thread is running, and locked so the main thread can't proceed to lock. The web thread can't proceed, with dispatch_sync, because the main thread is busy.
Try using dispatch_async instead. This should do the trick if the _volumeView is not going to be used immediately in the WebThread.
(In reply to comment #6) > This fix is not good. It deadlocks the app if the main thread is doing > something related to the web view, because at the time of . > > We're getting this freeze quite often, and get different stacks in the main > thread, ending with: > > thread #1: tid = 0x10919d, 0x33473ba8 > libsystem_kernel.dylib`__psynch_mutexwait + 24, queue = > 'com.apple.main-thread', stop reason = signal SIGSTOP > * frame #0: 0x33473ba8 libsystem_kernel.dylib`__psynch_mutexwait + 24 > frame #1: 0x334f103a libsystem_pthread.dylib`_pthread_mutex_lock + 394 > frame #2: 0x307fdf20 WebCore`_WebTryThreadLock(bool) + 44 > frame #3: 0x307fe736 WebCore`WebThreadLock + 82 > > While the WebThread will wait on dispatch_sync(dispatch_get_main_queue(), > ...). The web thread is running, and locked so the main thread can't proceed > to lock. The web thread can't proceed, with dispatch_sync, because the main > thread is busy. > > Try using dispatch_async instead. This should do the trick if the > _volumeView is not going to be used immediately in the WebThread. Thank you for the information. Please feel free to submit patches if you have suggestions for changes. UIWebView frequently crashes on iOS because of this bug and the proposed patch does not fix the problem. A reproducible example has been provided with rdar://problem/18609955 The allocateVolumeView method checks for isMainThread() which is implemented as: (isWebThread() || pthread_main_np()) Since this is called from the web thread, isMainThread returns true. Also, MPVolumeView gets allocated twice in the case where isMainThread() is false. Once on the main thread and then another time on the background thread (which is what we are trying to avoid here). |