Fix bug in active page tracking that lead to plugins hanging during destruction
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Jun 2013 01:39:17 +0000 (01:39 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 Jun 2013 01:39:17 +0000 (01:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117099

Reviewed by Anders Carlsson.

NPRuntimeObjectMap no longer keeps its own reference to the
throttler, and no longer reports activity during destruction.

* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::NPRuntimeObjectMap):
(WebKit::NPRuntimeObjectMap::evaluate):
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::PluginView):

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

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h
Source/WebKit2/WebProcess/Plugins/PluginView.cpp

index e9a2add..a2b489a 100644 (file)
@@ -1,3 +1,20 @@
+2013-05-31  Oliver Hunt  <oliver@apple.com>
+
+        Fix bug in active page tracking that lead to plugins hanging during destruction
+        https://bugs.webkit.org/show_bug.cgi?id=117099
+
+        Reviewed by Anders Carlsson.
+
+        NPRuntimeObjectMap no longer keeps its own reference to the
+        throttler, and no longer reports activity during destruction.
+
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::NPRuntimeObjectMap):
+        (WebKit::NPRuntimeObjectMap::evaluate):
+        * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.h:
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::PluginView):
+
 2013-05-31  Tim Horton  <timothy_horton@apple.com>
 
         [wk2] All intrinsic content size changes should go through the 0-delay timer
index ef06418..9956f1f 100644 (file)
@@ -51,9 +51,8 @@ using namespace WebCore;
 namespace WebKit {
 
 
-NPRuntimeObjectMap::NPRuntimeObjectMap(PluginView* pluginView, PageThrottler* pageThrottler)
+NPRuntimeObjectMap::NPRuntimeObjectMap(PluginView* pluginView)
     : m_pluginView(pluginView)
-    , m_pageThrottler(pageThrottler)
     , m_finalizationTimer(RunLoop::main(), this, &NPRuntimeObjectMap::invalidateQueuedObjects)
 {
 }
@@ -185,11 +184,15 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu
 
 bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result)
 {
-    m_pageThrottler->reportInterestingEvent();
     Strong<JSGlobalObject> globalObject(this->globalObject()->vm(), this->globalObject());
     if (!globalObject)
         return false;
 
+    if (m_pluginView && !m_pluginView->isBeingDestroyed()) {
+        if (Page* page = m_pluginView->frame()->page())
+            page->pageThrottler()->reportInterestingEvent();
+    }
+
     ExecState* exec = globalObject->globalExec();
     
     JSLockHolder lock(exec);
index 7585afe..e5178ad 100644 (file)
@@ -45,10 +45,6 @@ namespace JSC {
     class JSValue;
 }
 
-namespace WebCore {
-    class PageThrottler;
-}
-
 namespace WebKit {
 
 class JSNPObject;
@@ -58,7 +54,7 @@ class PluginView;
 // A per plug-in map of NPObjects that wrap JavaScript objects.
 class NPRuntimeObjectMap : private JSC::WeakHandleOwner {
 public:
-    explicit NPRuntimeObjectMap(PluginView*, WebCore::PageThrottler*);
+    explicit NPRuntimeObjectMap(PluginView*);
 
     class PluginProtector {
     public:
@@ -99,7 +95,6 @@ private:
     void invalidateQueuedObjects();
 
     PluginView* m_pluginView;
-    RefPtr<WebCore::PageThrottler> m_pageThrottler;
     HashMap<JSC::JSObject*, NPJSObject*> m_npJSObjects;
     HashMap<NPObject*, JSC::Weak<JSNPObject>> m_jsNPObjects;
     Vector<NPObject*> m_npObjectsToFinalize;
index d914e9a..14e6203 100644 (file)
@@ -278,7 +278,7 @@ PluginView::PluginView(PassRefPtr<HTMLPlugInElement> pluginElement, PassRefPtr<P
     , m_isBeingDestroyed(false)
     , m_pendingURLRequestsTimer(RunLoop::main(), this, &PluginView::pendingURLRequestsTimerFired)
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    , m_npRuntimeObjectMap(this, m_webPage->corePage()->pageThrottler())
+    , m_npRuntimeObjectMap(this)
 #endif
     , m_manualStreamState(StreamStateInitial)
     , m_pluginSnapshotTimer(this, &PluginView::pluginSnapshotTimerFired, pluginSnapshotTimerDelay)