Unreviewed, rolling out r191728.
https://bugs.webkit.org/show_bug.cgi?id=150668
Caused a lot of timeouts in layout tests (Requested by KaL on
#webkit).
Reverted changeset:
"[GTK] Use a persistent main loop source in RunLoop glib
implementation"
https://bugs.webkit.org/show_bug.cgi?id=150590
http://trac.webkit.org/changeset/191728
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@191729 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index d918e45..3a078a9 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,18 @@
+2015-10-29 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r191728.
+ https://bugs.webkit.org/show_bug.cgi?id=150668
+
+ Caused a lot of timeouts in layout tests (Requested by KaL on
+ #webkit).
+
+ Reverted changeset:
+
+ "[GTK] Use a persistent main loop source in RunLoop glib
+ implementation"
+ https://bugs.webkit.org/show_bug.cgi?id=150590
+ http://trac.webkit.org/changeset/191728
+
2015-10-29 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Use a persistent main loop source in RunLoop glib implementation
diff --git a/Source/WTF/wtf/RunLoop.h b/Source/WTF/wtf/RunLoop.h
index 9b159e6..6f30236 100644
--- a/Source/WTF/wtf/RunLoop.h
+++ b/Source/WTF/wtf/RunLoop.h
@@ -36,7 +36,7 @@
#include <wtf/Threading.h>
#if USE(GLIB)
-#include <wtf/glib/GRefPtr.h>
+#include <wtf/glib/GMainLoopSource.h>
#endif
#if PLATFORM(EFL)
@@ -100,10 +100,7 @@
Ecore_Timer* m_timer;
bool m_isRepeating;
#elif USE(GLIB)
- void updateReadyTime();
- GRefPtr<GSource> m_source;
- bool m_isRepeating { false };
- std::chrono::microseconds m_fireInterval { 0 };
+ GMainLoopSource m_timerSource;
#endif
};
@@ -158,9 +155,11 @@
static void wakeUpEvent(void* data, void*, unsigned);
#elif USE(GLIB)
+public:
+ static gboolean queueWork(RunLoop*);
+private:
GRefPtr<GMainContext> m_mainContext;
Vector<GRefPtr<GMainLoop>> m_mainLoops;
- GRefPtr<GSource> m_source;
#endif
};
diff --git a/Source/WTF/wtf/glib/MainThreadGLib.cpp b/Source/WTF/wtf/glib/MainThreadGLib.cpp
index d2e121f..649a9a5 100644
--- a/Source/WTF/wtf/glib/MainThreadGLib.cpp
+++ b/Source/WTF/wtf/glib/MainThreadGLib.cpp
@@ -30,7 +30,7 @@
#include "config.h"
#include "MainThread.h"
-#include <wtf/RunLoop.h>
+#include <wtf/glib/GMainLoopSource.h>
namespace WTF {
@@ -40,7 +40,7 @@
void scheduleDispatchFunctionsOnMainThread()
{
- RunLoop::main().dispatch(std::function<void()>(dispatchFunctionsFromMainThread));
+ GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] dispatchFunctionsFromMainThread", std::function<void()>(dispatchFunctionsFromMainThread));
}
} // namespace WTF
diff --git a/Source/WTF/wtf/glib/RunLoopGLib.cpp b/Source/WTF/wtf/glib/RunLoopGLib.cpp
index c70834b..7dc4075 100644
--- a/Source/WTF/wtf/glib/RunLoopGLib.cpp
+++ b/Source/WTF/wtf/glib/RunLoopGLib.cpp
@@ -32,22 +32,6 @@
namespace WTF {
-static GSourceFuncs runLoopSourceFunctions = {
- nullptr, // prepare
- nullptr, // check
- // dispatch
- [](GSource* source, GSourceFunc callback, gpointer userData) -> gboolean
- {
- if (g_source_get_ready_time(source) == -1)
- return G_SOURCE_CONTINUE;
- g_source_set_ready_time(source, -1);
- return callback(userData);
- },
- nullptr, // finalize
- nullptr, // closure_callback
- nullptr, // closure_marshall
-};
-
RunLoop::RunLoop()
{
m_mainContext = g_main_context_get_thread_default();
@@ -58,22 +42,10 @@
GRefPtr<GMainLoop> innermostLoop = adoptGRef(g_main_loop_new(m_mainContext.get(), FALSE));
ASSERT(innermostLoop);
m_mainLoops.append(innermostLoop);
-
- m_source = adoptGRef(g_source_new(&runLoopSourceFunctions, sizeof(GSource)));
- g_source_set_name(m_source.get(), "[WebKit] RunLoop work");
- g_source_set_can_recurse(m_source.get(), TRUE);
- g_source_set_ready_time(m_source.get(), -1);
- g_source_set_callback(m_source.get(), [](gpointer userData) -> gboolean {
- static_cast<RunLoop*>(userData)->performWork();
- return G_SOURCE_CONTINUE;
- }, this, nullptr);
- g_source_attach(m_source.get(), m_mainContext.get());
}
RunLoop::~RunLoop()
{
- g_source_destroy(m_source.get());
-
for (int i = m_mainLoops.size() - 1; i >= 0; --i) {
if (!g_main_loop_is_running(m_mainLoops[i].get()))
continue;
@@ -110,8 +82,6 @@
void RunLoop::stop()
{
- g_source_set_ready_time(m_source.get(), -1);
-
// The innermost main loop should always be there.
ASSERT(!m_mainLoops.isEmpty());
GRefPtr<GMainLoop> lastMainLoop = m_mainLoops.last();
@@ -121,50 +91,37 @@
void RunLoop::wakeUp()
{
- g_source_set_ready_time(m_source.get(), g_get_monotonic_time());
+ RefPtr<RunLoop> runLoop(this);
+ GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] RunLoop work", std::function<void()>([runLoop] {
+ runLoop->performWork();
+ }), G_PRIORITY_DEFAULT, nullptr, m_mainContext.get());
+ g_main_context_wakeup(m_mainContext.get());
}
RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
: m_runLoop(runLoop)
- , m_source(adoptGRef(g_source_new(&runLoopSourceFunctions, sizeof(GSource))))
{
- g_source_set_name(m_source.get(), "[WebKit] RunLoop::Timer work");
- g_source_set_ready_time(m_source.get(), -1);
- g_source_set_callback(m_source.get(), [](gpointer userData) -> gboolean {
- RunLoop::TimerBase* timer = static_cast<RunLoop::TimerBase*>(userData);
- timer->fired();
- if (timer->m_isRepeating)
- timer->updateReadyTime();
- return G_SOURCE_CONTINUE;
- }, this, nullptr);
- g_source_attach(m_source.get(), m_runLoop.m_mainContext.get());
}
RunLoop::TimerBase::~TimerBase()
{
- g_source_destroy(m_source.get());
-}
-
-void RunLoop::TimerBase::updateReadyTime()
-{
- g_source_set_ready_time(m_source.get(), m_fireInterval.count() ? g_get_monotonic_time() + m_fireInterval.count() : 0);
+ stop();
}
void RunLoop::TimerBase::start(double fireInterval, bool repeat)
{
- m_fireInterval = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(fireInterval));
- m_isRepeating = repeat;
- updateReadyTime();
+ m_timerSource.scheduleAfterDelay("[WebKit] RunLoop::Timer", std::function<bool ()>([this, repeat] { fired(); return repeat; }),
+ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::duration<double>(fireInterval)), G_PRIORITY_DEFAULT, nullptr, m_runLoop.m_mainContext.get());
}
void RunLoop::TimerBase::stop()
{
- g_source_set_ready_time(m_source.get(), -1);
+ m_timerSource.cancel();
}
bool RunLoop::TimerBase::isActive() const
{
- return g_source_get_ready_time(m_source.get()) != -1;
+ return m_timerSource.isScheduled();
}
} // namespace WTF
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index fddea48..b621bdb 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,18 @@
+2015-10-29 Commit Queue <commit-queue@webkit.org>
+
+ Unreviewed, rolling out r191728.
+ https://bugs.webkit.org/show_bug.cgi?id=150668
+
+ Caused a lot of timeouts in layout tests (Requested by KaL on
+ #webkit).
+
+ Reverted changeset:
+
+ "[GTK] Use a persistent main loop source in RunLoop glib
+ implementation"
+ https://bugs.webkit.org/show_bug.cgi?id=150590
+ http://trac.webkit.org/changeset/191728
+
2015-10-29 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] Use a persistent main loop source in RunLoop glib implementation
diff --git a/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp b/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
index 37a536a..5bc07c7 100644
--- a/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
+++ b/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
@@ -30,7 +30,8 @@
#include "NetworkCacheFileSystem.h"
#include <wtf/MainThread.h>
-#include <wtf/RunLoop.h>
+#include <wtf/glib/GMainLoopSource.h>
+#include <wtf/glib/GMutexLocker.h>
#include <wtf/glib/GUniquePtr.h>
namespace WebKit {
@@ -77,7 +78,7 @@
}
// Using nullptr as queue submits the result to the main context.
- RunLoop::main().dispatch(WTF::move(task));
+ GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] IOChannel task", WTF::move(task));
}
static void fillDataFromReadBuffer(SoupBuffer* readBuffer, size_t size, Data& data)
diff --git a/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp b/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp
index 113f868..304b6be 100644
--- a/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp
+++ b/Source/WebKit2/UIProcess/gtk/DragAndDropHandler.cpp
@@ -35,7 +35,7 @@
#include <WebCore/GtkUtilities.h>
#include <WebCore/PasteboardHelper.h>
#include <gtk/gtk.h>
-#include <wtf/RunLoop.h>
+#include <wtf/glib/GMainLoopSource.h>
#include <wtf/glib/GUniquePtr.h>
using namespace WebCore;
@@ -221,7 +221,7 @@
// During a drop GTK+ will fire a drag-leave signal right before firing
// the drag-drop signal. We want the actions for drag-leave to happen after
// those for drag-drop, so schedule them to happen asynchronously here.
- RunLoop::main().dispatch([this, droppingContext]() {
+ GMainLoopSource::scheduleAndDeleteOnDestroy("[WebKit] handleDragLeaveLater", [this, droppingContext]() {
auto it = m_droppingContexts.find(droppingContext->gdkContext);
if (it == m_droppingContexts.end())
return;