Bug 184861 - Web Inspector: opt out of process swap on navigation if a Web Inspector frontend is connected
Summary: Web Inspector: opt out of process swap on navigation if a Web Inspector front...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: BJ Burg
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-04-21 11:29 PDT by BJ Burg
Modified: 2018-05-07 10:10 PDT (History)
12 users (show)

See Also:


Attachments
Patch (14.38 KB, patch)
2018-04-21 11:39 PDT, BJ Burg
no flags Details | Formatted Diff | Diff
Fix API Test (14.37 KB, patch)
2018-05-04 17:06 PDT, BJ Burg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2018-04-21 11:29:49 PDT
<rdar://problem/39153768>
Comment 1 BJ Burg 2018-04-21 11:39:10 PDT
Created attachment 338528 [details]
Patch

For some reason this always crashes under WKInpectorClose() when we send -_apiObject inside unwrap(). But when I pause in the debugger in Safari, the wrapper is always allocated and valid. I'm not quite sure what's going on with the API test.
Comment 2 BJ Burg 2018-04-21 11:39:58 PDT
Comment on attachment 338528 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:1060
> +    WKInspectorClose(inspector.get());

(Previous comment should have been for this line.)
Comment 3 WebKit Commit Bot 2018-05-02 12:17:54 PDT
Comment on attachment 338528 [details]
Patch

Clearing flags on attachment: 338528

Committed r231253: <https://trac.webkit.org/changeset/231253>
Comment 4 WebKit Commit Bot 2018-05-02 12:17:56 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Ryan Haddad 2018-05-02 15:56:03 PDT
The API test added with this change is crashing on the bots:

13:29:24.633 33618 Crashed
13:29:24.633 33618 
13:29:24.633 33618     TestWebKitAPI.ProcessSwap.DisableForInspector
13:29:24.633 33618         Received data during response processing, queuing it.
13:29:24.633 33618         Received data during response processing, queuing it.
13:29:24.633 33618         2018-05-02 13:26:13.933 TestWebKitAPI[35988:32391770] -[_NSViewLayoutAux _apiObject]: unrecognized selector sent to instance 0x7fc5fd46e8a0
13:29:24.633 33618         2018-05-02 13:26:13.941 TestWebKitAPI[35988:32391770] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_NSViewLayoutAux _apiObject]: unrecognized selector sent to instance 0x7fc5fd46e8a0'
13:29:24.633 33618         *** First throw call stack:
13:29:24.634 33618         (
13:29:24.634 33618         	0   CoreFoundation                      0x00007fff2ce7c6bb __exceptionPreprocess + 171
13:29:24.634 33618         	1   libobjc.A.dylib                     0x00007fff54585942 objc_exception_throw + 48
13:29:24.634 33618         	2   CoreFoundation                      0x00007fff2cf139e4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
13:29:24.634 33618         	3   CoreFoundation                      0x00007fff2cdf4183 ___forwarding___ + 1443
13:29:24.634 33618         	4   CoreFoundation                      0x00007fff2cdf3b58 _CF_forwarding_prep_0 + 120
13:29:24.634 33618         	5   WebKit                              0x000000010411f23e _ZN3API6Object6unwrapEPv + 22
13:29:24.634 33618         	6   WebKit                              0x00000001044c2ff5 WKInspectorClose + 9
13:29:24.634 33618         	7   TestWebKitAPI                       0x000000010244cf3f _ZN36ProcessSwap_DisableForInspector_Test8TestBodyEv + 699
13:29:24.634 33618         	8   TestWebKitAPI                       0x0000000102560688 _ZN7testing4Test3RunEv + 92
13:29:24.634 33618         	9   TestWebKitAPI                       0x0000000102560ee4 _ZN7testing8internal12TestInfoImpl3RunEv + 180
13:29:24.634 33618         	10  TestWebKitAPI                       0x00000001025612cc _ZN7testing8TestCase3RunEv + 196
13:29:24.634 33618         	11  TestWebKitAPI                       0x0000000102564aa6 _ZN7testing8internal12UnitTestImpl11RunAllTestsEv + 614
13:29:24.634 33618         	12  TestWebKitAPI                       0x0000000102491d48 _ZN13TestWebKitAPI15TestsController3runEiPPc + 120
13:29:24.634 33618         	13  TestWebKitAPI                       0x0000000102540527 main + 344
13:29:24.634 33618         	14  libdyld.dylib                       0x00007fff5519c015 start + 1
13:29:24.634 33618         )
13:29:24.634 33618         libc++abi.dylib: terminating with uncaught exception of type NSException
13:29:24.634 33618 

https://build.webkit.org/builders/Apple%20High%20Sierra%20Release%20WK1%20%28Tests%29/builds/5062/steps/run-api-tests/logs/stdio
Comment 6 Ryan Haddad 2018-05-03 09:01:32 PDT
Reverted r231253 for reason:

The API test added with this change is crashing on the bots.

Committed r231306: <https://trac.webkit.org/changeset/231306>
Comment 7 BJ Burg 2018-05-04 16:33:07 PDT
(In reply to Ryan Haddad from comment #5)
> The API test added with this change is crashing on the bots:
> 
> 13:29:24.633 33618 Crashed
> 13:29:24.633 33618 
> 13:29:24.633 33618     TestWebKitAPI.ProcessSwap.DisableForInspector
> 13:29:24.633 33618         Received data during response processing, queuing
> it.
> 13:29:24.633 33618         Received data during response processing, queuing
> it.
> 13:29:24.633 33618         2018-05-02 13:26:13.933
> TestWebKitAPI[35988:32391770] -[_NSViewLayoutAux _apiObject]: unrecognized
> selector sent to instance 0x7fc5fd46e8a0
> 13:29:24.633 33618         2018-05-02 13:26:13.941
> TestWebKitAPI[35988:32391770] *** Terminating app due to uncaught exception
> 'NSInvalidArgumentException', reason: '-[_NSViewLayoutAux _apiObject]:
> unrecognized selector sent to instance 0x7fc5fd46e8a0'
> 13:29:24.633 33618         *** First throw call stack:
> 13:29:24.634 33618         (
> 13:29:24.634 33618         	0   CoreFoundation                     
> 0x00007fff2ce7c6bb __exceptionPreprocess + 171
> 13:29:24.634 33618         	1   libobjc.A.dylib                    
> 0x00007fff54585942 objc_exception_throw + 48
> 13:29:24.634 33618         	2   CoreFoundation                     
> 0x00007fff2cf139e4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
> 13:29:24.634 33618         	3   CoreFoundation                     
> 0x00007fff2cdf4183 ___forwarding___ + 1443
> 13:29:24.634 33618         	4   CoreFoundation                     
> 0x00007fff2cdf3b58 _CF_forwarding_prep_0 + 120
> 13:29:24.634 33618         	5   WebKit                             
> 0x000000010411f23e _ZN3API6Object6unwrapEPv + 22
> 13:29:24.634 33618         	6   WebKit                             
> 0x00000001044c2ff5 WKInspectorClose + 9
> 13:29:24.634 33618         	7   TestWebKitAPI                      
> 0x000000010244cf3f _ZN36ProcessSwap_DisableForInspector_Test8TestBodyEv + 699
> 13:29:24.634 33618         	8   TestWebKitAPI                      
> 0x0000000102560688 _ZN7testing4Test3RunEv + 92
> 13:29:24.634 33618         	9   TestWebKitAPI                      
> 0x0000000102560ee4 _ZN7testing8internal12TestInfoImpl3RunEv + 180
> 13:29:24.634 33618         	10  TestWebKitAPI                      
> 0x00000001025612cc _ZN7testing8TestCase3RunEv + 196
> 13:29:24.634 33618         	11  TestWebKitAPI                      
> 0x0000000102564aa6 _ZN7testing8internal12UnitTestImpl11RunAllTestsEv + 614
> 13:29:24.634 33618         	12  TestWebKitAPI                      
> 0x0000000102491d48 _ZN13TestWebKitAPI15TestsController3runEiPPc + 120
> 13:29:24.634 33618         	13  TestWebKitAPI                      
> 0x0000000102540527 main + 344
> 13:29:24.634 33618         	14  libdyld.dylib                      
> 0x00007fff5519c015 start + 1
> 13:29:24.634 33618         )
> 13:29:24.634 33618         libc++abi.dylib: terminating with uncaught
> exception of type NSException
> 13:29:24.634 33618 
> 
> https://build.webkit.org/builders/
> Apple%20High%20Sierra%20Release%20WK1%20%28Tests%29/builds/5062/steps/run-
> api-tests/logs/stdio

I don't know why an object with class NSViewLayoutAux is the receiver of -_apiObject. My understanding is that there is a WKObject that wraps the WebInspectorProxy because it lacks a custom ObjC API/wrapper class. So _apiObject would just be casting the extra space in WKObject.

Update: my new explanation is the WebInspectorProxy gets deallocated when the WebPageProxy resets state under WebPageProxy::continueNavigationInNewProcess(). So the cached WKInspectorRef is now garbage. We need a new reference. Now that this doesn't crash, there are other issues to resolve. I'll post a patch with an updated test.
Comment 8 BJ Burg 2018-05-04 16:55:03 PDT
The last issue is that _developerExtrasEnabled was not set for the WKPreferences used by the webview, so InspectorController::enabled() returns false and WKInspectorShow doesn't actually show an inspector. Easy enough to fix..
Comment 9 BJ Burg 2018-05-04 17:06:03 PDT
Created attachment 339615 [details]
Fix API Test
Comment 10 WebKit Commit Bot 2018-05-07 10:10:40 PDT
Comment on attachment 339615 [details]
Fix API Test

Clearing flags on attachment: 339615

Committed r231439: <https://trac.webkit.org/changeset/231439>
Comment 11 WebKit Commit Bot 2018-05-07 10:10:41 PDT
All reviewed patches have been landed.  Closing bug.