- Revision
- 275241
- Author
- [email protected]
- Date
- 2021-03-30 15:01:48 -0700 (Tue, 30 Mar 2021)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (275240 => 275241)
--- trunk/Source/WebCore/ChangeLog 2021-03-30 22:01:40 UTC (rev 275240)
+++ trunk/Source/WebCore/ChangeLog 2021-03-30 22:01:48 UTC (rev 275241)
@@ -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-30 Peng Liu <[email protected]>
[GPUP] Add an IPC message to implement RemoteImageDecoderAVF::clearFrameBufferCache()
Modified: trunk/Source/WebCore/dom/TaskSource.h (275240 => 275241)
--- trunk/Source/WebCore/dom/TaskSource.h 2021-03-30 22:01:40 UTC (rev 275240)
+++ trunk/Source/WebCore/dom/TaskSource.h 2021-03-30 22:01:48 UTC (rev 275241)
@@ -37,6 +37,7 @@
MediaElement,
Microtask,
Networking,
+ PerformanceTimeline,
PostedMessageQueue,
Speech,
UserInteraction,
Modified: trunk/Source/WebCore/page/Performance.cpp (275240 => 275241)
--- trunk/Source/WebCore/page/Performance.cpp 2021-03-30 22:01:40 UTC (rev 275240)
+++ trunk/Source/WebCore/page/Performance.cpp 2021-03-30 22:01:48 UTC (rev 275241)
@@ -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: trunk/Source/WebCore/page/Performance.h (275240 => 275241)
--- trunk/Source/WebCore/page/Performance.h 2021-03-30 22:01:40 UTC (rev 275240)
+++ trunk/Source/WebCore/page/Performance.h 2021-03-30 22:01:48 UTC (rev 275241)
@@ -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: trunk/Source/WebCore/platform/GenericTaskQueue.h (275240 => 275241)
--- trunk/Source/WebCore/platform/GenericTaskQueue.h 2021-03-30 22:01:40 UTC (rev 275240)
+++ trunk/Source/WebCore/platform/GenericTaskQueue.h 2021-03-30 22:01:48 UTC (rev 275241)
@@ -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()