Bug 143682

Summary: Web Inspector: Auto-attach fails after r179562, initialization too late after dispatch
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: Web InspectorAssignee: Joseph Pecoraro <joepeck>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ggaren, graouts, joepeck, jonowells, mattbaker, msaboff, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
[PATCH] Proposed Fix timothy: review+, joepeck: commit-queue-

Description Joseph Pecoraro 2015-04-13 15:27:58 PDT
* SUMMARY
Auto-attach fails after r179562, initialization too late after dispatch.

The async initialization of the RemoteInspector singleton causes auto-attach to fail if for instance you have:

  int main() {
    [[[JSContext alloc] init] evaluateScript:@"debugger"];
    ...
  }

We should detect if we are on the main thread and do it synchronously, since that was the only reason we were dispatching to the main thread anyways.
Comment 1 Radar WebKit Bug Importer 2015-04-13 15:28:29 PDT
<rdar://problem/20525746>
Comment 2 Joseph Pecoraro 2015-04-13 15:30:02 PDT
Created attachment 250679 [details]
[PATCH] Proposed Fix
Comment 3 Joseph Pecoraro 2015-04-13 15:49:45 PDT
Comment on attachment 250679 [details]
[PATCH] Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=250679&action=review

> Source/JavaScriptCore/inspector/remote/RemoteInspector.mm:87
> -            dispatch_async(dispatch_get_main_queue(), ^{
> +            dispatch_block_t initialize = ^{

One could argue that we should just change the dispatch_async to be a dispatch_sync. I'm going to cq- while I think about that.
Comment 4 Joseph Pecoraro 2015-04-14 17:25:12 PDT
> One could argue that we should just change the dispatch_async to be a
> dispatch_sync. I'm going to cq- while I think about that.

I couldn't reproduce the issue I was thinking with background queues, so I'm going to keep this dispatch_async in the non-main thread case.
Comment 5 Joseph Pecoraro 2015-04-14 17:28:48 PDT
http://trac.webkit.org/changeset/182825