Title: [187630] trunk/Source/WebCore
Revision
187630
Author
akl...@apple.com
Date
2015-07-30 17:52:45 -0700 (Thu, 30 Jul 2015)

Log Message

[CF] Web process continually eating memory on simple, shared Google Docs spreadsheet.
<https://webkit.org/b/147403>
<rdar://problem/18835799>

Reviewed by Geoffrey Garen.

Make sure we service the CFRunLoop on worker threads, since ports using CoreFoundation
will be scheduling garbage collections and heap sweeps using CFRunLoop timers.

This fix is a stopgap. Long term we need a better design for integrating GC tasks with
with the web worker run loop.

* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::runInMode): Instead of sleeping forever, calculate a better
wakeup deadline by asking the CFRunLoop when its next timer will fire. Then, when a
timeout occurs, call CFRunLoopRunInMode (with seconds=0) to service pending timers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187629 => 187630)


--- trunk/Source/WebCore/ChangeLog	2015-07-31 00:43:25 UTC (rev 187629)
+++ trunk/Source/WebCore/ChangeLog	2015-07-31 00:52:45 UTC (rev 187630)
@@ -1,3 +1,22 @@
+2015-07-30  Andreas Kling  <akl...@apple.com>
+
+        [CF] Web process continually eating memory on simple, shared Google Docs spreadsheet.
+        <https://webkit.org/b/147403>
+        <rdar://problem/18835799>
+
+        Reviewed by Geoffrey Garen.
+
+        Make sure we service the CFRunLoop on worker threads, since ports using CoreFoundation
+        will be scheduling garbage collections and heap sweeps using CFRunLoop timers.
+
+        This fix is a stopgap. Long term we need a better design for integrating GC tasks with
+        with the web worker run loop.
+
+        * workers/WorkerRunLoop.cpp:
+        (WebCore::WorkerRunLoop::runInMode): Instead of sleeping forever, calculate a better
+        wakeup deadline by asking the CFRunLoop when its next timer will fire. Then, when a
+        timeout occurs, call CFRunLoopRunInMode (with seconds=0) to service pending timers.
+
 2015-07-30  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Move locale information into FontDescription

Modified: trunk/Source/WebCore/workers/WorkerRunLoop.cpp (187629 => 187630)


--- trunk/Source/WebCore/workers/WorkerRunLoop.cpp	2015-07-31 00:43:25 UTC (rev 187629)
+++ trunk/Source/WebCore/workers/WorkerRunLoop.cpp	2015-07-31 00:52:45 UTC (rev 187630)
@@ -148,9 +148,21 @@
     ASSERT(context);
     ASSERT(context->thread().threadID() == currentThread());
 
+    double deadline = MessageQueue<Task>::infiniteTime();
+
+#if USE(CF)
+    CFAbsoluteTime nextCFRunLoopTimerFireDate = CFRunLoopGetNextTimerFireDate(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+    double timeUntilNextCFRunLoopTimerInSeconds = nextCFRunLoopTimerFireDate - CFAbsoluteTimeGetCurrent();
+    deadline = currentTime() + std::max(0.0, timeUntilNextCFRunLoopTimerInSeconds);
+#endif
+
     double absoluteTime = 0.0;
-    if (waitMode == WaitForMessage)
-        absoluteTime = (predicate.isDefaultMode() && m_sharedTimer->isActive()) ? m_sharedTimer->fireTime() : MessageQueue<Task>::infiniteTime();
+    if (waitMode == WaitForMessage) {
+        if (predicate.isDefaultMode() && m_sharedTimer->isActive())
+            absoluteTime = std::min(deadline, m_sharedTimer->fireTime());
+        else
+            absoluteTime = deadline;
+    }
     MessageQueueWaitResult result;
     auto task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, absoluteTime);
 
@@ -167,6 +179,10 @@
     case MessageQueueTimeout:
         if (!context->isClosing())
             m_sharedTimer->fire();
+#if USE(CF)
+        if (nextCFRunLoopTimerFireDate <= CFAbsoluteTimeGetCurrent())
+            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, /*returnAfterSourceHandled*/ false);
+#endif
         break;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to