⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282489 in webkit


Ignore:
Timestamp:
Sep 16, 2021, 12:22:45 AM (5 years ago)
Author:
Adrian Perez de Castro
Message:

Merge r275241 - 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.

Location:
releases/WebKitGTK/webkit-2.32/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog

    r281304 r282489  
     12021-03-30  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Occasional debug assert in GenericTaskQueue::~GenericTaskQueue
     4        https://bugs.webkit.org/show_bug.cgi?id=223913
     5
     6        Reviewed by Eric Carlson.
     7
     8        Eagerly initialize WeakPtrImpl so that we don't hit debug assertions.
     9
     10        Also made Performance object use EventLoop.
     11
     12        No new tests since there is no test case that reliably reproduces this issue.
     13
     14        * dom/TaskSource.h:
     15        (TaskSource): Added PerformanceTimeline.
     16        * page/Performance.cpp:
     17        (WebCore::Performance::Performance):
     18        (WebCore::Performance::contextDestroyed):
     19        (WebCore::Performance::queueEntry): Use EventLoopTaskGroup instead of GenericTaskQueue to deliver entries.
     20        * page/Performance.h:
     21        * platform/GenericTaskQueue.h:
     22        (WebCore::GenericTaskQueue::GenericTaskQueue): Eagerly initialize WeakPtrImpl.
     23        Also assert that we're creating this object in the main thread.
     24
    1252021-03-29  Chris Dumez  <cdumez@apple.com>
    226
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/TaskSource.h

    r269348 r282489  
    3737    Microtask,
    3838    Networking,
     39    PerformanceTimeline,
    3940    PostedMessageQueue,
    4041    UserInteraction,
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.cpp

    r267402 r282489  
    3737#include "DocumentLoader.h"
    3838#include "Event.h"
     39#include "EventLoop.h"
    3940#include "EventNames.h"
    4041#include "Frame.h"
    … …  
    5859Performance::Performance(ScriptExecutionContext* context, MonotonicTime timeOrigin)
    5960    : ContextDestructionObserver(context)
    60     , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired)
     61    , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired) // FIXME: Migrate this to the event loop as well.
    6162    , m_timeOrigin(timeOrigin)
    62     , m_performanceTimelineTaskQueue(context)
    6363{
    6464    ASSERT(m_timeOrigin);
    65     ASSERT(context || m_performanceTimelineTaskQueue.isClosed());
    6665}
    6766
    … …  
    7069void Performance::contextDestroyed()
    7170{
    72     m_performanceTimelineTaskQueue.close();
    7371    m_resourceTimingBufferFullTimer.stop();
    7472    ContextDestructionObserver::contextDestroyed();
    … …  
    369367        return;
    370368
    371     if (m_performanceTimelineTaskQueue.hasPendingTasks())
    372         return;
    373 
    374     m_performanceTimelineTaskQueue.enqueueTask([this] () {
     369    if (m_hasScheduledTimingBufferDeliveryTask)
     370        return;
     371
     372    auto* context = scriptExecutionContext();
     373    if (!context)
     374        return;
     375
     376    m_hasScheduledTimingBufferDeliveryTask = true;
     377    context->eventLoop().queueTask(TaskSource::PerformanceTimeline, [protectedThis = makeRef(*this), this] {
     378        auto* context = scriptExecutionContext();
     379        if (!context)
     380            return;
     381
     382        m_hasScheduledTimingBufferDeliveryTask = false;
    375383        for (auto& observer : copyToVector(m_observers))
    376384            observer->deliver();
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/page/Performance.h

    r267402 r282489  
    3737#include "EventTarget.h"
    3838#include "ExceptionOr.h"
    39 #include "GenericTaskQueue.h"
    4039#include "ReducedResolutionSeconds.h"
     40#include "ScriptExecutionContext.h"
     41#include "Timer.h"
    4142#include <wtf/ListHashSet.h>
    4243#include <wtf/Variant.h>
    … …  
    135136    bool m_resourceTimingBufferFullFlag { false };
    136137    bool m_waitingForBackupBufferToBeProcessed { false };
     138    bool m_hasScheduledTimingBufferDeliveryTask { false };
    137139
    138140    MonotonicTime m_timeOrigin;
    … …  
    141143    std::unique_ptr<PerformanceUserTiming> m_userTiming;
    142144
    143     GenericTaskQueue<ScriptExecutionContext> m_performanceTimelineTaskQueue;
    144145    ListHashSet<RefPtr<PerformanceObserver>> m_observers;
    145146};
  • releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/GenericTaskQueue.h

    r259593 r282489  
    5959
    6060template<>
    61 class TaskDispatcher<Timer> : public CanMakeWeakPtr<TaskDispatcher<Timer>> {
     61class TaskDispatcher<Timer> : public CanMakeWeakPtr<TaskDispatcher<Timer>, WeakPtrFactoryInitialization::Eager> {
    6262    WTF_MAKE_FAST_ALLOCATED;
    6363public:
    … …  
    8383        : m_dispatcher(makeUniqueRef<TaskDispatcher<T>>())
    8484    {
     85        ASSERT(isMainThread());
    8586    }
    8687
    … …  
    8889        : m_dispatcher(makeUniqueRef<TaskDispatcher<T>>(&t))
    8990    {
     91        ASSERT(isMainThread());
    9092    }
    9193
    … …  
    9496        , m_isClosed(!t)
    9597    {
     98        ASSERT(isMainThread());
    9699    }
    97100
Note: See TracChangeset for help on using the changeset viewer.