Random crashes on the Web Thread due to Timers firing on the wrong thread in the...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jul 2014 22:17:24 +0000 (22:17 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jul 2014 22:17:24 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135132
<rdar://problem/17719832>

Reviewed by Simon Fraser.

* UIProcess/ProcessThrottler.cpp:
(WebKit::ProcessThrottler::ProcessThrottler):
(WebKit::ProcessThrottler::suspendTimerFired):
* UIProcess/ProcessThrottler.h:
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
We can't use WebCore timers in the UI process because of coexistence concerns
(they fire on the Web Thread if there is one!), so use RunLoop::Timer instead.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ProcessThrottler.cpp
Source/WebKit2/UIProcess/ProcessThrottler.h
Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit2/UIProcess/mac/ViewGestureController.h
Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm

index 2cb4dafc753b53d16b2cfc93b34ba8cf2570ada2..e41168e8acb1aae2101c33b0368093bb6d44e4fe 100644 (file)
@@ -1,3 +1,25 @@
+2014-07-21  Timothy Horton  <timothy_horton@apple.com>
+
+        Random crashes on the Web Thread due to Timers firing on the wrong thread in the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=135132
+        <rdar://problem/17719832>
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/ProcessThrottler.cpp:
+        (WebKit::ProcessThrottler::ProcessThrottler):
+        (WebKit::ProcessThrottler::suspendTimerFired):
+        * UIProcess/ProcessThrottler.h:
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
+        * UIProcess/mac/ViewGestureController.h:
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::swipeSnapshotWatchdogTimerFired):
+        We can't use WebCore timers in the UI process because of coexistence concerns
+        (they fire on the Web Thread if there is one!), so use RunLoop::Timer instead.
+
 2014-07-21  Andy Estes  <aestes@apple.com>
 
         [iOS] Handle QuickLook ResourceLoaders in the web process
index b9b6d8686b533c03a415ebeb0d90f612508aa402..21a45af13f69fc6fd3a63407ef443e57ad528494 100644 (file)
@@ -65,7 +65,7 @@ ProcessThrottler::BackgroundActivityToken::~BackgroundActivityToken()
 ProcessThrottler::ProcessThrottler(WebProcessProxy* process)
     : m_process(process)
     , m_weakPtrFactory(this)
-    , m_suspendTimer(this, &ProcessThrottler::suspendTimerFired)
+    , m_suspendTimer(RunLoop::main(), this, &ProcessThrottler::suspendTimerFired)
     , m_foregroundCount(0)
     , m_backgroundCount(0)
     , m_suspendMessageCount(0)
@@ -116,7 +116,7 @@ void ProcessThrottler::didConnnectToProcess(pid_t pid)
     m_assertion = std::make_unique<ProcessAndUIAssertion>(pid, assertionState());
 }
     
-void ProcessThrottler::suspendTimerFired(WebCore::Timer<ProcessThrottler>*)
+void ProcessThrottler::suspendTimerFired()
 {
     updateAssertionNow();
 }
index c7129ccde0fb8b57af685412b6bdbaed8300134a..f30c1b6eafe113d8064796af1fddbce176e5e4c8 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "ProcessAssertion.h"
 
-#include <WebCore/Timer.h>
+#include <wtf/RunLoop.h>
 #include <wtf/WeakPtr.h>
 
 namespace WebKit {
@@ -69,12 +69,12 @@ private:
     AssertionState assertionState();
     void updateAssertion();
     void updateAssertionNow();
-    void suspendTimerFired(WebCore::Timer<ProcessThrottler>*);
+    void suspendTimerFired();
     
     WebProcessProxy* m_process;
     WeakPtrFactory<ProcessThrottler> m_weakPtrFactory;
     std::unique_ptr<ProcessAndUIAssertion> m_assertion;
-    WebCore::Timer<ProcessThrottler> m_suspendTimer;
+    RunLoop::Timer<ProcessThrottler> m_suspendTimer;
     unsigned m_foregroundCount;
     unsigned m_backgroundCount;
     int m_suspendMessageCount;
index 58be849e9c87d4e23e81adb8e075597850884d87..8fe9a6e15450c4a886e389c6f035cb1c2830396e 100644 (file)
@@ -136,7 +136,7 @@ namespace WebKit {
 ViewGestureController::ViewGestureController(WebPageProxy& webPageProxy)
     : m_webPageProxy(webPageProxy)
     , m_activeGestureType(ViewGestureType::None)
-    , m_swipeWatchdogTimer(this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
+    , m_swipeWatchdogTimer(RunLoop::main(), this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
     , m_snapshotRemovalTargetRenderTreeSize(0)
     , m_shouldRemoveSnapshotWhenTargetRenderTreeSizeHit(false)
 {
@@ -310,7 +310,7 @@ void ViewGestureController::setRenderTreeSize(uint64_t renderTreeSize)
         removeSwipeSnapshot();
 }
 
-void ViewGestureController::swipeSnapshotWatchdogTimerFired(Timer<ViewGestureController>*)
+void ViewGestureController::swipeSnapshotWatchdogTimerFired()
 {
     removeSwipeSnapshot();
 }
index a8857a4c563df0dc65c61f358edbb1b6361aa115..e8e9babeb058a91e56fd6e095631e58639dbcc0f 100644 (file)
@@ -29,8 +29,8 @@
 #include "MessageReceiver.h"
 #include "WeakObjCPtr.h"
 #include <WebCore/FloatRect.h>
-#include <WebCore/Timer.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/RunLoop.h>
 
 OBJC_CLASS CALayer;
 
@@ -119,7 +119,7 @@ private:
     virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
     
     void removeSwipeSnapshot();
-    void swipeSnapshotWatchdogTimerFired(WebCore::Timer<ViewGestureController>*);
+    void swipeSnapshotWatchdogTimerFired();
 
 #if PLATFORM(MAC)
     // Message handlers.
@@ -146,7 +146,7 @@ private:
     WebPageProxy& m_webPageProxy;
     ViewGestureType m_activeGestureType;
     
-    WebCore::Timer<ViewGestureController> m_swipeWatchdogTimer;
+    RunLoop::Timer<ViewGestureController> m_swipeWatchdogTimer;
 
 #if USE(IOSURFACE)
     RefPtr<WebCore::IOSurface> m_currentSwipeSnapshotSurface;
index 4c4929712033c97fe89dd797e0f680b3caf3ff46..d2386cb32bc76c898b57e77f5dadb05f583d4e68 100644 (file)
@@ -97,7 +97,7 @@ namespace WebKit {
 ViewGestureController::ViewGestureController(WebPageProxy& webPageProxy)
     : m_webPageProxy(webPageProxy)
     , m_activeGestureType(ViewGestureType::None)
-    , m_swipeWatchdogTimer(this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
+    , m_swipeWatchdogTimer(RunLoop::main(), this, &ViewGestureController::swipeSnapshotWatchdogTimerFired)
     , m_lastMagnificationGestureWasSmartMagnification(false)
     , m_visibleContentRectIsValid(false)
     , m_frameHandlesMagnificationGesture(false)
@@ -657,7 +657,7 @@ void ViewGestureController::didHitRenderTreeSizeThreshold()
     removeSwipeSnapshot();
 }
 
-void ViewGestureController::swipeSnapshotWatchdogTimerFired(WebCore::Timer<ViewGestureController>*)
+void ViewGestureController::swipeSnapshotWatchdogTimerFired()
 {
     removeSwipeSnapshot();
 }