Diff
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog (282488 => 282489)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog 2021-09-16 05:48:23 UTC (rev 282488)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog 2021-09-16 07:22:45 UTC (rev 282489)
@@ -1,3 +1,27 @@
+2021-03-30 Ryosuke Niwa <[email protected]>
+
+ Occasional debug assert in GenericTaskQueue::~GenericTaskQueue
+ https://bugs.webkit.org/show_bug.cgi?id=223913
+
+ Reviewed by Eric Carlson.
+
+ Eagerly initialize WeakPtrImpl so that we don't hit debug assertions.
+
+ Also made Performance object use EventLoop.
+
+ No new tests since there is no test case that reliably reproduces this issue.
+
+ * dom/TaskSource.h:
+ (TaskSource): Added PerformanceTimeline.
+ * page/Performance.cpp:
+ (WebCore::Performance::Performance):
+ (WebCore::Performance::contextDestroyed):
+ (WebCore::Performance::queueEntry): Use EventLoopTaskGroup instead of GenericTaskQueue to deliver entries.
+ * page/Performance.h:
+ * platform/GenericTaskQueue.h:
+ (WebCore::GenericTaskQueue::GenericTaskQueue): Eagerly initialize WeakPtrImpl.
+ Also assert that we're creating this object in the main thread.
+
2021-03-29 Chris Dumez <[email protected]>
REGRESSION(r274992): Nullptr crash in FontCache::retrieveOrAddCachedFonts
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/TaskSource.h (282488 => 282489)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/TaskSource.h 2021-09-16 05:48:23 UTC (rev 282488)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/TaskSource.h 2021-09-16 07:22:45 UTC (rev 282489)
@@ -36,6 +36,7 @@
MediaElement,
Microtask,
Networking,
+ PerformanceTimeline,
PostedMessageQueue,
UserInteraction,
WebGL,
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.cpp (282488 => 282489)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.cpp 2021-09-16 05:48:23 UTC (rev 282488)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.cpp 2021-09-16 07:22:45 UTC (rev 282489)
@@ -36,6 +36,7 @@
#include "Document.h"
#include "DocumentLoader.h"
#include "Event.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Frame.h"
#include "PerformanceEntry.h"
@@ -57,12 +58,10 @@
Performance::Performance(ScriptExecutionContext* context, MonotonicTime timeOrigin)
: ContextDestructionObserver(context)
- , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired)
+ , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired) // FIXME: Migrate this to the event loop as well.
, m_timeOrigin(timeOrigin)
- , m_performanceTimelineTaskQueue(context)
{
ASSERT(m_timeOrigin);
- ASSERT(context || m_performanceTimelineTaskQueue.isClosed());
}
Performance::~Performance() = default;
@@ -69,7 +68,6 @@
void Performance::contextDestroyed()
{
- m_performanceTimelineTaskQueue.close();
m_resourceTimingBufferFullTimer.stop();
ContextDestructionObserver::contextDestroyed();
}
@@ -368,10 +366,20 @@
if (!shouldScheduleTask)
return;
- if (m_performanceTimelineTaskQueue.hasPendingTasks())
+ if (m_hasScheduledTimingBufferDeliveryTask)
return;
- m_performanceTimelineTaskQueue.enqueueTask([this] () {
+ auto* context = scriptExecutionContext();
+ if (!context)
+ return;
+
+ m_hasScheduledTimingBufferDeliveryTask = true;
+ context->eventLoop().queueTask(TaskSource::PerformanceTimeline, [protectedThis = makeRef(*this), this] {
+ auto* context = scriptExecutionContext();
+ if (!context)
+ return;
+
+ m_hasScheduledTimingBufferDeliveryTask = false;
for (auto& observer : copyToVector(m_observers))
observer->deliver();
});
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.h (282488 => 282489)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.h 2021-09-16 05:48:23 UTC (rev 282488)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.h 2021-09-16 07:22:45 UTC (rev 282489)
@@ -36,8 +36,9 @@
#include "DOMHighResTimeStamp.h"
#include "EventTarget.h"
#include "ExceptionOr.h"
-#include "GenericTaskQueue.h"
#include "ReducedResolutionSeconds.h"
+#include "ScriptExecutionContext.h"
+#include "Timer.h"
#include <wtf/ListHashSet.h>
#include <wtf/Variant.h>
@@ -134,6 +135,7 @@
// https://w3c.github.io/resource-timing/#dfn-resource-timing-buffer-full-flag
bool m_resourceTimingBufferFullFlag { false };
bool m_waitingForBackupBufferToBeProcessed { false };
+ bool m_hasScheduledTimingBufferDeliveryTask { false };
MonotonicTime m_timeOrigin;
@@ -140,7 +142,6 @@
RefPtr<PerformancePaintTiming> m_firstContentfulPaint;
std::unique_ptr<PerformanceUserTiming> m_userTiming;
- GenericTaskQueue<ScriptExecutionContext> m_performanceTimelineTaskQueue;
ListHashSet<RefPtr<PerformanceObserver>> m_observers;
};
Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/GenericTaskQueue.h (282488 => 282489)
--- releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/GenericTaskQueue.h 2021-09-16 05:48:23 UTC (rev 282488)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/GenericTaskQueue.h 2021-09-16 07:22:45 UTC (rev 282489)
@@ -58,7 +58,7 @@
};
template<>
-class TaskDispatcher<Timer> : public CanMakeWeakPtr<TaskDispatcher<Timer>> {
+class TaskDispatcher<Timer> : public CanMakeWeakPtr<TaskDispatcher<Timer>, WeakPtrFactoryInitialization::Eager> {
WTF_MAKE_FAST_ALLOCATED;
public:
TaskDispatcher();
@@ -82,11 +82,13 @@
GenericTaskQueue()
: m_dispatcher(makeUniqueRef<TaskDispatcher<T>>())
{
+ ASSERT(isMainThread());
}
explicit GenericTaskQueue(T& t)
: m_dispatcher(makeUniqueRef<TaskDispatcher<T>>(&t))
{
+ ASSERT(isMainThread());
}
explicit GenericTaskQueue(T* t)
@@ -93,6 +95,7 @@
: m_dispatcher(makeUniqueRef<TaskDispatcher<T>>(t))
, m_isClosed(!t)
{
+ ASSERT(isMainThread());
}
~GenericTaskQueue()