Web Inspector: Release InjectedScripts when frontends close
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 02:59:17 +0000 (02:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 May 2017 02:59:17 +0000 (02:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172313

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-05-18
Reviewed by Andreas Kling.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::disconnectFrontend):
Release inspector resources together, including discarding injected
scripts so that they may be collected.

(WebCore::InspectorController::inspectedPageDestroyed):
(WebCore::InspectorController::disconnectAllFrontends):
Move the disconnect call inside of disconnectAllFrontends to establish
a pattern of releasing web inspector resources together.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217087 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorController.cpp

index 374cc60..03c0b10 100644 (file)
@@ -1,3 +1,20 @@
+2017-05-18  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Release InjectedScripts when frontends close
+        https://bugs.webkit.org/show_bug.cgi?id=172313
+
+        Reviewed by Andreas Kling.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::disconnectFrontend):
+        Release inspector resources together, including discarding injected
+        scripts so that they may be collected.
+
+        (WebCore::InspectorController::inspectedPageDestroyed):
+        (WebCore::InspectorController::disconnectAllFrontends):
+        Move the disconnect call inside of disconnectAllFrontends to establish
+        a pattern of releasing web inspector resources together.
+
 2017-05-18  Simon Fraser  <simon.fraser@apple.com>
 
         Add a newline after the URL in showLayerTree output.
index 2d05e51..353523a 100644 (file)
@@ -202,8 +202,6 @@ InspectorController::~InspectorController()
 
 void InspectorController::inspectedPageDestroyed()
 {
-    m_injectedScriptManager->disconnect();
-
     // Clean up resources and disconnect local and remote frontends.
     disconnectAllFrontends();
 
@@ -283,8 +281,9 @@ void InspectorController::disconnectFrontend(FrontendChannel* frontendChannel)
         // Notify agents first.
         m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectorDestroyed);
 
-        // Destroy the inspector overlay's page.
+        // Clean up inspector resources.
         m_overlay->freePage();
+        m_injectedScriptManager->discardInjectedScripts();
 
         // Unplug all instrumentations since they aren't needed now.
         InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgents.get());
@@ -317,8 +316,9 @@ void InspectorController::disconnectAllFrontends()
     // Notify agents first, since they may need to use InspectorClient.
     m_agents.willDestroyFrontendAndBackend(DisconnectReason::InspectedTargetDestroyed);
 
-    // Destroy the inspector overlay's page.
+    // Clean up inspector resources.
     m_overlay->freePage();
+    m_injectedScriptManager->disconnect();
 
     // Disconnect any remaining remote frontends.
     m_frontendRouter->disconnectAllFrontends();