⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286498 in webkit


Ignore:
Timestamp:
Dec 3, 2021, 9:45:21 AM (5 years ago)
Author:
BJ Burg
Message:

Web Inspector: Web Inspector2 crashes after closing if Web Inspector1 closed first
https://bugs.webkit.org/show_bug.cgi?id=233293
<rdar://problem/85526508>

Reviewed by Devin Rousso.

Cache the inspected page's identifier. During frontend teardown, use the cached indentifier
to remove the message receiver that was added to receive messages from the inspected page.

Other operations using m_inspectedPage should be guarded in case that the inspected
page already been closed and destroyed.

  • UIProcess/Inspector/WebInspectorUIProxy.cpp:

(WebKit::WebInspectorUIProxy::createFrontendPage):
(WebKit::WebInspectorUIProxy::closeFrontendPageAndWindow):

  • UIProcess/Inspector/WebInspectorUIProxy.h:
Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r286497 r286498  
     12021-12-03  BJ Burg  <bburg@apple.com>
     2
     3        Web Inspector: Web Inspector^2 crashes after closing if Web Inspector^1 closed first
     4        https://bugs.webkit.org/show_bug.cgi?id=233293
     5        <rdar://problem/85526508>
     6
     7        Reviewed by Devin Rousso.
     8
     9        Cache the inspected page's identifier. During frontend teardown, use the cached indentifier
     10        to remove the message receiver that was added to receive messages from the inspected page.
     11
     12        Other operations using m_inspectedPage should be guarded in case that the inspected
     13        page already been closed and destroyed.
     14
     15        * UIProcess/Inspector/WebInspectorUIProxy.cpp:
     16        (WebKit::WebInspectorUIProxy::createFrontendPage):
     17        (WebKit::WebInspectorUIProxy::closeFrontendPageAndWindow):
     18        * UIProcess/Inspector/WebInspectorUIProxy.h:
     19
     20
    1212021-12-03  BJ Burg  <bburg@apple.com>
    222
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp

    r278253 r286498  
    11/*
    2  * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2021 Apple Inc. All rights reserved.
    33 * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
    44 *
     
    226226
    227227    m_inspectedPage = &inspectedPage;
     228    m_inspectedPageIdentifier = m_inspectedPage->identifier();
     229
    228230    m_inspectedPage->process().addMessageReceiver(Messages::WebInspectorUIProxy::messageReceiverName(), m_inspectedPage->webPageID(), *this);
    229231
     
    420422    m_inspectedPage->launchInitialProcessIfNecessary();
    421423
    422     m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorUIProxy::messageReceiverName(), m_inspectedPage->identifier(), *this);
     424    m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorUIProxy::messageReceiverName(), m_inspectedPageIdentifier, *this);
    423425
    424426#if ENABLE(INSPECTOR_EXTENSIONS)
     
    530532   
    531533    // Notify WebKit client when a local inspector closes so it can clear _WKInspectorDelegate and perform other cleanup.
    532     m_inspectedPage->uiClient().willCloseLocalInspector(*m_inspectedPage, *this);
     534    if (m_inspectedPage)
     535        m_inspectedPage->uiClient().willCloseLocalInspector(*m_inspectedPage, *this);
    533536
    534537    m_isVisible = false;
     
    540543
    541544    m_inspectorPage->send(Messages::WebInspectorUI::SetIsVisible(m_isVisible));
    542     m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorUIProxy::messageReceiverName(), m_inspectedPage->identifier());
    543 
    544     if (m_isActiveFrontend) {
    545         m_isActiveFrontend = false;
     545    m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorUIProxy::messageReceiverName(), m_inspectedPageIdentifier);
     546
     547    if (m_inspectedPage && m_isActiveFrontend)
    546548        m_inspectedPage->inspectorController().disconnectFrontend(*this);
    547     }
     549
     550    m_isActiveFrontend = false;
    548551
    549552    if (m_isAttached)
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h

    r278253 r286498  
    11/*
    2  * Copyright (C) 2010-2020 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2021 Apple Inc. All rights reserved.
    33 * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
    44 *
     
    3232#include "MessageReceiver.h"
    3333#include "WebInspectorUtilities.h"
     34#include "WebPageProxyIdentifier.h"
    3435#include <JavaScriptCore/InspectorFrontendChannel.h>
    3536#include <WebCore/FloatRect.h>
     
    289290    WebPageProxy* m_inspectorPage { nullptr };
    290291    std::unique_ptr<API::InspectorClient> m_inspectorClient;
     292    WebPageProxyIdentifier m_inspectedPageIdentifier;
    291293
    292294#if ENABLE(INSPECTOR_EXTENSIONS)
Note: See TracChangeset for help on using the changeset viewer.