Changeset 259103 in webkit


Ignore:
Timestamp:
Mar 26, 2020 9:20:20 PM (4 years ago)
Author:
Chris Dumez
Message:

REGRESSION: Unable to show Web Inspector on empty tabs in Safari
https://bugs.webkit.org/show_bug.cgi?id=209639
<rdar://problem/60937524>

Reviewed by Darin Adler.

Source/WebKit:

Make sure we launch the WebPageProxy's initial process when trying to inspect the
page using Web Inspector (i.e. WebInspectorProxy::connect() is called).

  • UIProcess/Inspector/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy):

  • Take in a reference instead of a raw pointer as it could never be null.
  • Store the inspected page and add the message receiver to its process, even if the process is the dummy one (due to delayed process launch).

(WebKit::WebInspectorProxy::invalidate):
Call reset() to avoid code duplication.

(WebKit::WebInspectorProxy::connect):
Launch the page's initial process if necessary before trying to send IPC to that
process.

(WebKit::WebInspectorProxy::updateForNewPageProcess):
Take in a reference instead of a raw pointer as it could never be null.

  • UIProcess/Inspector/WebInspectorProxy.h:

(WebKit::WebInspectorProxy::create):
Take in a reference instead of a raw pointer as it could never be null.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::launchProcess):
Call WebInspectorProxy::reset() before launching and connecting to the new process.
This is important now that the WebInspectorProxy connect to the dummy process proxy.
We need to make sure the WebInspectorProxy disconnects from the dummy process proxy
because we connect it to the newly launched process.

(WebKit::WebPageProxy::finishAttachingToWebProcess):

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259097 r259103  
     12020-03-26  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION: Unable to show Web Inspector on empty tabs in Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=209639
     5        <rdar://problem/60937524>
     6
     7        Reviewed by Darin Adler.
     8
     9        Make sure we launch the WebPageProxy's initial process when trying to inspect the
     10        page using Web Inspector (i.e. WebInspectorProxy::connect() is called).
     11
     12        * UIProcess/Inspector/WebInspectorProxy.cpp:
     13        (WebKit::WebInspectorProxy::WebInspectorProxy):
     14        - Take in a reference instead of a raw pointer as it could never be null.
     15        - Store the inspected page and add the message receiver to its process, even
     16          if the process is the dummy one (due to delayed process launch).
     17
     18        (WebKit::WebInspectorProxy::invalidate):
     19        Call reset() to avoid code duplication.
     20
     21        (WebKit::WebInspectorProxy::connect):
     22        Launch the page's initial process if necessary before trying to send IPC to that
     23        process.
     24
     25        (WebKit::WebInspectorProxy::updateForNewPageProcess):
     26        Take in a reference instead of a raw pointer as it could never be null.
     27
     28        * UIProcess/Inspector/WebInspectorProxy.h:
     29        (WebKit::WebInspectorProxy::create):
     30        Take in a reference instead of a raw pointer as it could never be null.
     31
     32        * UIProcess/WebPageProxy.cpp:
     33        (WebKit::WebPageProxy::launchProcess):
     34        Call WebInspectorProxy::reset() before launching and connecting to the new process.
     35        This is important now that the WebInspectorProxy connect to the dummy process proxy.
     36        We need to make sure the WebInspectorProxy disconnects from the dummy process proxy
     37        because we connect it to the newly launched process.
     38
     39        (WebKit::WebPageProxy::finishAttachingToWebProcess):
     40
    1412020-03-26  Chris Dumez  <cdumez@apple.com>
    242
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp

    r258245 r259103  
    6767const unsigned WebInspectorProxy::initialWindowHeight = 650;
    6868
    69 WebInspectorProxy::WebInspectorProxy(WebPageProxy* inspectedPage)
     69WebInspectorProxy::WebInspectorProxy(WebPageProxy& inspectedPage)
     70    : m_inspectedPage(&inspectedPage)
    7071#if PLATFORM(MAC)
    71     : m_closeFrontendAfterInactivityTimer(RunLoop::main(), this, &WebInspectorProxy::closeFrontendAfterInactivityTimerFired)
     72    , m_closeFrontendAfterInactivityTimer(RunLoop::main(), this, &WebInspectorProxy::closeFrontendAfterInactivityTimerFired)
    7273#endif
    7374{
    74     if (inspectedPage && inspectedPage->hasRunningProcess()) {
    75         m_inspectedPage = inspectedPage;
    76         m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->webPageID(), *this);
    77     }
     75    m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->webPageID(), *this);
    7876}
    7977
     
    9593void WebInspectorProxy::invalidate()
    9694{
    97     if (m_inspectedPage)
    98         m_inspectedPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->webPageID());
    99 
    10095    closeFrontendPageAndWindow();
    10196    platformInvalidate();
    10297
    103     m_inspectedPage = nullptr;
     98    reset();
    10499}
    105100
     
    134129    createFrontendPage();
    135130
     131    m_inspectedPage->launchInitialProcessIfNecessary();
    136132    m_inspectedPage->send(Messages::WebInspectorInterruptDispatcher::NotifyNeedDebuggerBreak(), 0);
    137133    m_inspectedPage->send(Messages::WebInspector::Show());
     
    214210}
    215211
    216 void WebInspectorProxy::updateForNewPageProcess(WebPageProxy* inspectedPage)
     212void WebInspectorProxy::updateForNewPageProcess(WebPageProxy& inspectedPage)
    217213{
    218214    ASSERT(!m_inspectedPage);
    219     ASSERT(inspectedPage);
    220 
    221     m_inspectedPage = inspectedPage;
     215
     216    m_inspectedPage = &inspectedPage;
    222217    m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_inspectedPage->webPageID(), *this);
    223218
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h

    r258245 r259103  
    8181{
    8282public:
    83     static Ref<WebInspectorProxy> create(WebPageProxy* inspectedPage)
     83    static Ref<WebInspectorProxy> create(WebPageProxy& inspectedPage)
    8484    {
    8585        return adoptRef(*new WebInspectorProxy(inspectedPage));
     
    108108
    109109    void reset();
    110     void updateForNewPageProcess(WebPageProxy*);
     110    void updateForNewPageProcess(WebPageProxy&);
    111111
    112112#if PLATFORM(MAC)
     
    182182
    183183private:
    184     explicit WebInspectorProxy(WebPageProxy*);
     184    explicit WebInspectorProxy(WebPageProxy&);
    185185
    186186    void createFrontendPage();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r259097 r259103  
    509509    m_pageGroup->addPage(this);
    510510
    511     m_inspector = WebInspectorProxy::create(this);
     511    m_inspector = WebInspectorProxy::create(*this);
    512512
    513513    if (hasRunningProcess())
     
    786786
    787787    RELEASE_LOG_IF_ALLOWED(Loading, "launchProcess:");
     788
     789    // In case we are currently connected to the dummy process, we need to make sure the inspector proxy
     790    // disconnects from the dummy process first.
     791    m_inspector->reset();
    788792
    789793    m_process->removeWebPage(*this, WebProcessProxy::EndsUsingDataStore::Yes);
     
    925929        initializeWebPage();
    926930
    927     m_inspector->updateForNewPageProcess(this);
     931    m_inspector->updateForNewPageProcess(*this);
    928932
    929933#if ENABLE(REMOTE_INSPECTOR)
  • trunk/Tools/ChangeLog

    r259102 r259103  
     12020-03-26  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION: Unable to show Web Inspector on empty tabs in Safari
     4        https://bugs.webkit.org/show_bug.cgi?id=209639
     5        <rdar://problem/60937524>
     6
     7        Reviewed by Darin Adler.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132020-03-26  Fujii Hironori  <Hironori.Fujii@sony.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r259100 r259103  
    39673967}
    39683968
     3969TEST(ProcessSwap, WebInspectorDelayedProcessLaunch)
     3970{
     3971    auto processPoolConfiguration = psonProcessPoolConfiguration();
     3972    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     3973
     3974    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     3975    [webViewConfiguration setProcessPool:processPool.get()];
     3976    webViewConfiguration.get().preferences._developerExtrasEnabled = YES;
     3977
     3978    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     3979
     3980    EXPECT_EQ(0, [webView _webProcessIdentifier]);
     3981    TestWebKitAPI::Util::spinRunLoop(100);
     3982    EXPECT_EQ(0, [webView _webProcessIdentifier]);
     3983
     3984    [[webView _inspector] show];
     3985    EXPECT_TRUE([[webView _inspector] isConnected]);
     3986
     3987    // Trying to inspect the view should launch a WebProcess.
     3988    while (![webView _webProcessIdentifier])
     3989        TestWebKitAPI::Util::spinRunLoop(10);
     3990    EXPECT_NE(0, [webView _webProcessIdentifier]);
     3991
     3992    [[webView _inspector] close];
     3993}
     3994
    39693995#endif // !TARGET_OS_IPHONE
    39703996
Note: See TracChangeset for help on using the changeset viewer.