ASSERTION FAILED: m_wrapper on imported/w3c/web-platform-tests/html/semantics/embedde...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2020 17:39:41 +0000 (17:39 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2020 17:39:41 +0000 (17:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209684
<rdar://problem/60987285>

Reviewed by Darin Adler.

I have not been able to reproduce so this is a speculative fix. HTMLMediaElement::virtualHasPendingActivity()
was checking MainThreadGenericEventQueue::hasPendingEvents() but this would return false for a short amount
of time where we've removed the last event from the queue and before we've actually fired the event. To
address the issue, we now rely on MainThreadGenericEventQueue::hasPendingActivity() which keeps returning
true after we've dequeued the last event, until we've fired it.

No new tests, covered by imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::virtualHasPendingActivity const):
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::virtualHasPendingActivity const):
* dom/GenericEventQueue.cpp:
(WebCore::MainThreadGenericEventQueue::dispatchOneEvent):
(WebCore::MainThreadGenericEventQueue::hasPendingActivity const):
(WebCore::MainThreadGenericEventQueue::hasPendingEvents const): Deleted.
* dom/GenericEventQueue.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::virtualHasPendingActivity const):
* html/track/TrackListBase.cpp:
(WebCore::TrackListBase::virtualHasPendingActivity const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@259299 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/dom/GenericEventQueue.cpp
Source/WebCore/dom/GenericEventQueue.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/track/TrackListBase.cpp

index e54ad20..490a03e 100644 (file)
@@ -1,3 +1,33 @@
+2020-03-31  Chris Dumez  <cdumez@apple.com>
+
+        ASSERTION FAILED: m_wrapper on imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html
+        https://bugs.webkit.org/show_bug.cgi?id=209684
+        <rdar://problem/60987285>
+
+        Reviewed by Darin Adler.
+
+        I have not been able to reproduce so this is a speculative fix. HTMLMediaElement::virtualHasPendingActivity()
+        was checking MainThreadGenericEventQueue::hasPendingEvents() but this would return false for a short amount
+        of time where we've removed the last event from the queue and before we've actually fired the event. To
+        address the issue, we now rely on MainThreadGenericEventQueue::hasPendingActivity() which keeps returning
+        true after we've dequeued the last event, until we've fired it.
+
+        No new tests, covered by imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html.
+
+        * Modules/mediasource/MediaSource.cpp:
+        (WebCore::MediaSource::virtualHasPendingActivity const):
+        * Modules/mediasource/SourceBuffer.cpp:
+        (WebCore::SourceBuffer::virtualHasPendingActivity const):
+        * dom/GenericEventQueue.cpp:
+        (WebCore::MainThreadGenericEventQueue::dispatchOneEvent):
+        (WebCore::MainThreadGenericEventQueue::hasPendingActivity const):
+        (WebCore::MainThreadGenericEventQueue::hasPendingEvents const): Deleted.
+        * dom/GenericEventQueue.h:
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::virtualHasPendingActivity const):
+        * html/track/TrackListBase.cpp:
+        (WebCore::TrackListBase::virtualHasPendingActivity const):
+
 2020-03-31  Chris Lord  <clord@igalia.com>
 
         requestAnimationFrame and cancelAnimationFrame should be present on DedicatedWorkerGlobalScope
index 401a37f..4d1aca5 100644 (file)
@@ -973,7 +973,7 @@ void MediaSource::openIfInEndedState()
 
 bool MediaSource::virtualHasPendingActivity() const
 {
-    return m_private || m_asyncEventQueue->hasPendingEvents();
+    return m_private || m_asyncEventQueue->hasPendingActivity();
 }
 
 void MediaSource::stop()
index 8974462..8d51d84 100644 (file)
@@ -537,7 +537,7 @@ MediaTime SourceBuffer::sourceBufferPrivateFastSeekTimeForMediaTime(const MediaT
 
 bool SourceBuffer::virtualHasPendingActivity() const
 {
-    return m_source || m_asyncEventQueue->hasPendingEvents();
+    return m_source || m_asyncEventQueue->hasPendingActivity();
 }
 
 void SourceBuffer::stop()
index cea08d7..e3ee8e8 100644 (file)
@@ -33,6 +33,7 @@
 #include "ScriptExecutionContext.h"
 #include "Timer.h"
 #include <wtf/MainThread.h>
+#include <wtf/SetForScope.h>
 
 namespace WebCore {
 
@@ -63,7 +64,9 @@ void MainThreadGenericEventQueue::dispatchOneEvent()
 {
     ASSERT(!m_pendingEvents.isEmpty());
 
+    SetForScope<bool> eventFiringScope(m_isFiringEvent, true);
     Ref<EventTarget> protect(m_owner);
+
     RefPtr<Event> event = m_pendingEvents.takeFirst();
     EventTarget& target = event->target() ? *event->target() : m_owner;
     ASSERT_WITH_MESSAGE(!target.scriptExecutionContext()->activeDOMObjectsAreStopped(),
@@ -86,9 +89,9 @@ void MainThreadGenericEventQueue::cancelAllEvents()
     m_pendingEvents.clear();
 }
 
-bool MainThreadGenericEventQueue::hasPendingEvents() const
+bool MainThreadGenericEventQueue::hasPendingActivity() const
 {
-    return !m_pendingEvents.isEmpty();
+    return !m_pendingEvents.isEmpty() || m_isFiringEvent;
 }
 
 bool MainThreadGenericEventQueue::hasPendingEventsOfType(const AtomString& type) const
index 60fde57..5a3e4f5 100644 (file)
@@ -50,13 +50,14 @@ public:
     void close();
 
     void cancelAllEvents();
-    bool hasPendingEvents() const;
     bool hasPendingEventsOfType(const AtomString&) const;
 
     void setPaused(bool);
 
     bool isSuspended() const { return m_isSuspended; }
 
+    bool hasPendingActivity() const;
+
 private:
     friend UniqueRef<MainThreadGenericEventQueue> WTF::makeUniqueRefWithoutFastMallocCheck<MainThreadGenericEventQueue, WebCore::EventTarget&>(WebCore::EventTarget&);
     explicit MainThreadGenericEventQueue(EventTarget&);
@@ -77,6 +78,7 @@ private:
     bool m_isClosed { false };
     bool m_isPausedByClient { false };
     bool m_isSuspended { false };
+    bool m_isFiringEvent { false };
 };
 
 } // namespace WebCore
index 7420510..5679c42 100644 (file)
@@ -5764,7 +5764,7 @@ void HTMLMediaElement::resume()
 
 bool HTMLMediaElement::virtualHasPendingActivity() const
 {
-    return (hasAudio() && isPlaying()) || m_asyncEventQueue->hasPendingEvents() || m_playbackTargetIsWirelessQueue.hasPendingTasks() || m_creatingControls;
+    return (hasAudio() && isPlaying()) || m_asyncEventQueue->hasPendingActivity() || m_playbackTargetIsWirelessQueue.hasPendingTasks() || m_creatingControls;
 }
 
 void HTMLMediaElement::mediaVolumeDidChange()
index 98c057e..bdba8f7 100644 (file)
@@ -179,7 +179,7 @@ bool TrackListBase::isAnyTrackEnabled() const
 
 bool TrackListBase::virtualHasPendingActivity() const
 {
-    return m_asyncEventQueue->hasPendingEvents();
+    return m_asyncEventQueue->hasPendingActivity();
 }
 
 } // namespace WebCore