Remove WTF::setMainThreadCallbacksPaused
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2020 00:27:44 +0000 (00:27 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2020 00:27:44 +0000 (00:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213112

Reviewed by Tim Horton.

Source/WebCore:

* inspector/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::setJavaScriptPaused):

Source/WTF:

setMainThreadCallbacksPaused pauses all uses of callOnMainThread. That
has too many side-effects. For example, you can scroll, but you can't
paint any large images (since they do async image decoding).

Meanwhile, setMainThreadCallbacksPaused doesn't pause RunLoop::dispatch.
So, other things don't get paused.

Let's just rely on suspending the ScriptExecutionContext and document
event queue. That should suspend JavaScript-visible stuff without
suspending engine-critical stuff.

* wtf/MainThread.cpp:
(WTF::dispatchFunctionsFromMainThread):
(WTF::setMainThreadCallbacksPaused): Deleted.
* wtf/MainThread.h:

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

Source/WTF/ChangeLog
Source/WTF/wtf/MainThread.cpp
Source/WTF/wtf/MainThread.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/PageScriptDebugServer.cpp

index a1ac3e9..8191d1a 100644 (file)
@@ -1,3 +1,26 @@
+2020-06-23  Geoffrey Garen  <ggaren@apple.com>
+
+        Remove WTF::setMainThreadCallbacksPaused
+        https://bugs.webkit.org/show_bug.cgi?id=213112
+
+        Reviewed by Tim Horton.
+
+        setMainThreadCallbacksPaused pauses all uses of callOnMainThread. That
+        has too many side-effects. For example, you can scroll, but you can't
+        paint any large images (since they do async image decoding).
+
+        Meanwhile, setMainThreadCallbacksPaused doesn't pause RunLoop::dispatch.
+        So, other things don't get paused.
+
+        Let's just rely on suspending the ScriptExecutionContext and document
+        event queue. That should suspend JavaScript-visible stuff without
+        suspending engine-critical stuff.
+
+        * wtf/MainThread.cpp:
+        (WTF::dispatchFunctionsFromMainThread):
+        (WTF::setMainThreadCallbacksPaused): Deleted.
+        * wtf/MainThread.h:
+
 2020-06-23  Chris Dumez  <cdumez@apple.com>
 
         Remove a lot of unnecessary calls to Ref::copyRef()
 2020-06-23  Chris Dumez  <cdumez@apple.com>
 
         Remove a lot of unnecessary calls to Ref::copyRef()
index bf95206..65fff16 100644 (file)
@@ -41,7 +41,6 @@
 
 namespace WTF {
 
 
 namespace WTF {
 
-static bool callbacksPaused; // This global variable is only accessed from main thread.
 static Lock mainThreadFunctionQueueMutex;
 
 static Deque<Function<void ()>>& functionQueue()
 static Lock mainThreadFunctionQueueMutex;
 
 static Deque<Function<void ()>>& functionQueue()
@@ -74,9 +73,6 @@ void dispatchFunctionsFromMainThread()
 {
     ASSERT(isMainThread());
 
 {
     ASSERT(isMainThread());
 
-    if (callbacksPaused)
-        return;
-
     auto startTime = MonotonicTime::now();
 
     Function<void ()> function;
     auto startTime = MonotonicTime::now();
 
     Function<void ()> function;
@@ -132,19 +128,6 @@ void callOnMainThread(Function<void()>&& function)
         scheduleDispatchFunctionsOnMainThread();
 }
 
         scheduleDispatchFunctionsOnMainThread();
 }
 
-void setMainThreadCallbacksPaused(bool paused)
-{
-    ASSERT(isMainThread());
-
-    if (callbacksPaused == paused)
-        return;
-
-    callbacksPaused = paused;
-
-    if (!callbacksPaused)
-        scheduleDispatchFunctionsOnMainThread();
-}
-
 bool isMainThreadOrGCThread()
 {
     if (Thread::mayBeGCThread())
 bool isMainThreadOrGCThread()
 {
     if (Thread::mayBeGCThread())
index eba2ca1..f9ad23d 100644 (file)
@@ -50,8 +50,6 @@ WTF_EXPORT_PRIVATE void dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded(void
 WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());
 #endif
 
 WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());
 #endif
 
-WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
-
 WTF_EXPORT_PRIVATE bool isMainThread();
 
 WTF_EXPORT_PRIVATE bool canCurrentThreadAccessThreadLocalData(Thread&);
 WTF_EXPORT_PRIVATE bool isMainThread();
 
 WTF_EXPORT_PRIVATE bool canCurrentThreadAccessThreadLocalData(Thread&);
@@ -88,7 +86,6 @@ using WTF::isMainThread;
 using WTF::isMainThreadOrGCThread;
 using WTF::isUIThread;
 using WTF::isWebThread;
 using WTF::isMainThreadOrGCThread;
 using WTF::isUIThread;
 using WTF::isWebThread;
-using WTF::setMainThreadCallbacksPaused;
 #if PLATFORM(COCOA)
 using WTF::dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded;
 using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
 #if PLATFORM(COCOA)
 using WTF::dispatchAsyncOnMainThreadWithWebThreadLockIfNeeded;
 using WTF::callOnWebThreadOrDispatchAsyncOnMainThread;
index 6f55121..caca3a1 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-23  Geoffrey Garen  <ggaren@apple.com>
+
+        Remove WTF::setMainThreadCallbacksPaused
+        https://bugs.webkit.org/show_bug.cgi?id=213112
+
+        Reviewed by Tim Horton.
+
+        * inspector/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::setJavaScriptPaused):
+
 2020-06-23  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, update xcfilelist files after some recent WebXR changes.
 2020-06-23  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, update xcfilelist files after some recent WebXR changes.
index 958b2e6..17a66f1 100644 (file)
@@ -135,8 +135,6 @@ void PageScriptDebugServer::reportException(JSGlobalObject* state, JSC::Exceptio
 
 void PageScriptDebugServer::setJavaScriptPaused(const PageGroup& pageGroup, bool paused)
 {
 
 void PageScriptDebugServer::setJavaScriptPaused(const PageGroup& pageGroup, bool paused)
 {
-    setMainThreadCallbacksPaused(paused);
-
     for (auto& page : pageGroup.pages()) {
         for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
             setJavaScriptPaused(*frame, paused);
     for (auto& page : pageGroup.pages()) {
         for (Frame* frame = &page->mainFrame(); frame; frame = frame->tree().traverseNext())
             setJavaScriptPaused(*frame, paused);