Bug 143682 - Web Inspector: Auto-attach fails after r179562, initialization too late after dispatch
Summary: Web Inspector: Auto-attach fails after r179562, initialization too late after...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-04-13 15:27 PDT by Joseph Pecoraro
Modified: 2015-04-14 17:28 PDT (History)
10 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (1.92 KB, patch)
2015-04-13 15:30 PDT, Joseph Pecoraro
timothy: review+
joepeck: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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