Diff
Modified: trunk/Source/WTF/ChangeLog (278579 => 278580)
--- trunk/Source/WTF/ChangeLog 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WTF/ChangeLog 2021-06-08 00:29:50 UTC (rev 278580)
@@ -1,3 +1,37 @@
+2021-06-07 Chris Dumez <[email protected]>
+
+ Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes
+ https://bugs.webkit.org/show_bug.cgi?id=226734
+
+ Reviewed by Ryosuke Niwa.
+
+ We recently introduced the WTF::CancellableTask in order to be able to cancel
+ a pending task in the event loop, and/or check if the task is still pending.
+ It worked great as a replacement for EventLoopDeferrableTask. However, it was
+ insufficient as a replacement for task queues (such as MainThreadTaskQueue &
+ EventLoopTaskQueue) since there was no convenient way to cancel a group of
+ tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one
+ needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup.
+ Several CancellableTask objects can share the same TaskCancellationGroup. Code now
+ now schedule one or more CancellableTasks on the event loop and hold on
+ to a TaskCancellationGroup. If they need to cancel those tasks, they can simply
+ call cancel() on the TaskCancellationGroup. They can also check if previously
+ scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask().
+
+ * wtf/CancellableTask.h:
+ (WTF::TaskCancellationGroup::TaskCancellationGroup):
+ (WTF::TaskCancellationGroup::cancel):
+ (WTF::TaskCancellationGroup::hasPendingTask const):
+ (WTF::TaskCancellationGroup::Impl::cancel):
+ (WTF::TaskCancellationGroup::Impl::hasPendingTask const):
+ (WTF::TaskCancellationGroup::Handle::isCancelled const):
+ (WTF::TaskCancellationGroup::Handle::Handle):
+ (WTF::TaskCancellationGroup::createHandle):
+ (WTF::CancellableTask::CancellableTask):
+ (WTF::CancellableTask::operator()):
+ * wtf/WeakPtr.h:
+ (WTF::WeakPtrFactory::weakPtrCount const):
+
2021-06-07 Wenson Hsieh <[email protected]>
Upstream WebKit support for Live Text
Modified: trunk/Source/WTF/wtf/CancellableTask.h (278579 => 278580)
--- trunk/Source/WTF/wtf/CancellableTask.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WTF/wtf/CancellableTask.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -31,59 +31,62 @@
namespace WTF {
-namespace Detail {
-struct CancellableTaskImpl : public CanMakeWeakPtr<CancellableTaskImpl> {
- WTF_MAKE_STRUCT_FAST_ALLOCATED;
- explicit CancellableTaskImpl(Function<void()>&& task) : task(WTFMove(task)) { }
- Function<void()> task;
-};
-}
+class CancellableTask;
-class CancellableTask {
+class TaskCancellationGroup : public CanMakeWeakPtr<TaskCancellationGroup> {
public:
- explicit CancellableTask(Function<void()>&&);
+ TaskCancellationGroup() : m_impl(makeUniqueRef<Impl>()) { }
+ void cancel() { m_impl->cancel(); }
+ bool hasPendingTask() const { return m_impl->hasPendingTask(); }
- void operator()();
- bool isPending() const { return !!m_taskWrapper->task; }
- void cancel() { m_taskWrapper->task = nullptr; }
+private:
+ friend class CancellableTask;
+ class Impl : public CanMakeWeakPtr<Impl> {
+ WTF_MAKE_FAST_ALLOCATED;
+ public:
+ void cancel() { weakPtrFactory().revokeAll(); }
+ bool hasPendingTask() const { return weakPtrFactory().weakPtrCount(); }
+ };
class Handle {
public:
- Handle() = default;
- bool isPending() const { return m_taskWrapper && m_taskWrapper->task; }
- void cancel();
+ bool isCancelled() const { return !m_impl; }
+ void clear() { m_impl = nullptr; }
private:
- friend class CancellableTask;
- explicit Handle(Detail::CancellableTaskImpl&);
- WeakPtr<Detail::CancellableTaskImpl> m_taskWrapper;
+ friend class TaskCancellationGroup;
+ explicit Handle(Impl& impl) : m_impl(makeWeakPtr(impl)) { }
+ WeakPtr<Impl> m_impl;
};
+ Handle createHandle() { return Handle { m_impl }; }
- Handle createHandle() { return Handle { m_taskWrapper.get() }; }
+ UniqueRef<Impl> m_impl;
+};
+class CancellableTask {
+public:
+ CancellableTask(TaskCancellationGroup&, Function<void()>&&);
+ void operator()();
+
private:
- UniqueRef<Detail::CancellableTaskImpl> m_taskWrapper;
+ TaskCancellationGroup::Handle m_cancellationGroup;
+ Function<void()> m_task;
};
-inline CancellableTask::CancellableTask(Function<void()>&& task)
- : m_taskWrapper(makeUniqueRef<Detail::CancellableTaskImpl>(WTFMove(task)))
+inline CancellableTask::CancellableTask(TaskCancellationGroup& cancellationGroup, Function<void()>&& task)
+ : m_cancellationGroup(cancellationGroup.createHandle())
+ , m_task(WTFMove(task))
{ }
inline void CancellableTask::operator()()
{
- if (auto task = std::exchange(m_taskWrapper->task, nullptr))
- task();
-}
+ if (m_cancellationGroup.isCancelled())
+ return;
-inline CancellableTask::Handle::Handle(Detail::CancellableTaskImpl& task)
- : m_taskWrapper(makeWeakPtr(task))
-{ }
-
-inline void CancellableTask::Handle::cancel()
-{
- if (m_taskWrapper)
- m_taskWrapper->task = nullptr;
+ m_cancellationGroup.clear();
+ m_task();
}
} // namespace WTF
using WTF::CancellableTask;
+using WTF::TaskCancellationGroup;
Modified: trunk/Source/WTF/wtf/WeakPtr.h (278579 => 278580)
--- trunk/Source/WTF/wtf/WeakPtr.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WTF/wtf/WeakPtr.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -185,6 +185,8 @@
m_impl = nullptr;
}
+ unsigned weakPtrCount() const { return m_impl ? m_impl->refCount() - 1 : 0; }
+
#if ASSERT_ENABLED
bool isInitialized() const { return m_impl; }
#endif
Modified: trunk/Source/WebCore/ChangeLog (278579 => 278580)
--- trunk/Source/WebCore/ChangeLog 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/ChangeLog 2021-06-08 00:29:50 UTC (rev 278580)
@@ -1,3 +1,63 @@
+2021-06-07 Chris Dumez <[email protected]>
+
+ Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes
+ https://bugs.webkit.org/show_bug.cgi?id=226734
+
+ Reviewed by Ryosuke Niwa.
+
+ Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue
+ is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the
+ HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task
+ is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so.
+
+ * Headers.cmake:
+ * Modules/encryptedmedia/MediaKeySystemAccess.cpp:
+ * WebCore.xcodeproj/project.pbxproj:
+ * animation/DocumentTimelinesController.cpp:
+ (WebCore::DocumentTimelinesController::cacheCurrentTime):
+ (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime):
+ * animation/DocumentTimelinesController.h:
+ * dom/ActiveDOMObject.h:
+ * dom/Document.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::HTMLMediaElement):
+ (WebCore::HTMLMediaElement::~HTMLMediaElement):
+ (WebCore::HTMLMediaElement::scheduleNextSourceChild):
+ (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability):
+ (WebCore::HTMLMediaElement::seekWithTolerance):
+ (WebCore::HTMLMediaElement::setVolume):
+ (WebCore::HTMLMediaElement::scheduleConfigureTextTracks):
+ (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated):
+ (WebCore::HTMLMediaElement::scheduleUpdatePlayState):
+ (WebCore::HTMLMediaElement::cancelPendingTasks):
+ (WebCore::HTMLMediaElement::clearMediaPlayer):
+ (WebCore::HTMLMediaElement::closeTaskQueues):
+ (WebCore::HTMLMediaElement::suspend):
+ (WebCore::HTMLMediaElement::resume):
+ (WebCore::HTMLMediaElement::virtualHasPendingActivity const):
+ (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured):
+ (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged):
+ (WebCore::HTMLMediaElement::scheduleUpdateMediaState):
+ (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired):
+ * html/HTMLMediaElement.h:
+ * platform/GenericTaskQueue.h: Removed.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (-[WebCoreAVFMovieObserver metadataLoaded]):
+ (-[WebCoreAVFMovieObserver didEnd:]):
+ (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
+ (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]):
+ (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]):
+ (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]):
+ (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]):
+ (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]):
+ (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]):
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
+ (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):
+ (WebCore::SourceBufferPrivateAVFObjC::abort):
+ * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h:
+
2021-06-07 Wenson Hsieh <[email protected]>
Upstream WebKit support for Live Text
Modified: trunk/Source/WebCore/Headers.cmake (278579 => 278580)
--- trunk/Source/WebCore/Headers.cmake 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/Headers.cmake 2021-06-08 00:29:50 UTC (rev 278580)
@@ -1034,7 +1034,6 @@
platform/FileMonitor.h
platform/FileStreamClient.h
platform/FloatConversion.h
- platform/GenericTaskQueue.h
platform/HostWindow.h
platform/KeyedCoding.h
platform/KeypressCommand.h
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp (278579 => 278580)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySystemAccess.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -34,6 +34,7 @@
#include "CDM.h"
#include "CDMInstance.h"
#include "Document.h"
+#include "EventLoop.h"
#include "JSDOMPromiseDeferred.h"
#include "JSMediaKeys.h"
#include "MediaKeys.h"
Modified: trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp (278579 => 278580)
--- trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/Modules/mediacapabilities/MediaCapabilities.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -28,6 +28,7 @@
#include "ContentType.h"
#include "Document.h"
+#include "EventLoop.h"
#include "JSDOMPromiseDeferred.h"
#include "JSMediaCapabilitiesDecodingInfo.h"
#include "JSMediaCapabilitiesEncodingInfo.h"
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (278579 => 278580)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-06-08 00:29:50 UTC (rev 278580)
@@ -4386,7 +4386,6 @@
CD5FF49C2162E4CF004BD86F /* ISOProtectionSystemSpecificHeaderBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 12F75A9A86EA03DAF24B7971 /* ISOProtectionSystemSpecificHeaderBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD5FF49D2162E4DB004BD86F /* ISOProtectionSchemeInfoBox.h in Headers */ = {isa = PBXBuildFile; fileRef = CD871C601FB52B6500F0B965 /* ISOProtectionSchemeInfoBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD5FF49E2162E4E8004BD86F /* ISOOriginalFormatBox.h in Headers */ = {isa = PBXBuildFile; fileRef = CD871C671FB52B6800F0B965 /* ISOOriginalFormatBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
- CD62FB961AF018E70012ED7D /* GenericTaskQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD641EB31818F5ED00EE4C41 /* MediaSourcePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD641EB41818F5ED00EE4C41 /* SourceBufferPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD720B4F2268B51300047FDE /* ISOFairPlayStreamingPsshBox.h in Headers */ = {isa = PBXBuildFile; fileRef = CD720B4922682C7F00047FDE /* ISOFairPlayStreamingPsshBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -14999,7 +14998,6 @@
CD5D27761E8318E000D80A3D /* WebCoreDecompressionSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreDecompressionSession.h; sourceTree = "<group>"; };
CD5E5B5E1A15CE54000C609E /* PageConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageConfiguration.h; sourceTree = "<group>"; };
CD5E5B601A15F156000C609E /* PageConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageConfiguration.cpp; sourceTree = "<group>"; };
- CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GenericTaskQueue.h; sourceTree = "<group>"; };
CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
CD641EB21818F5ED00EE4C41 /* SourceBufferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivate.h; sourceTree = "<group>"; };
CD641EC7181ED60100EE4C41 /* MediaSample.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSample.h; sourceTree = "<group>"; };
@@ -28068,7 +28066,6 @@
BC073BA90C399B1F000F5979 /* FloatConversion.h */,
4190F3A1249D152700531C57 /* FrameRateMonitor.cpp */,
4190F3A3249D152800531C57 /* FrameRateMonitor.h */,
- CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */,
A8748BDF12CBF2DC001FBA41 /* HashTools.h */,
BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */,
@@ -32787,7 +32784,6 @@
C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */,
BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */,
830030F61B7D33B500ED3AAC /* GenericCachedHTMLCollection.h in Headers */,
- CD62FB961AF018E70012ED7D /* GenericTaskQueue.h in Headers */,
9746AF2414F4DDE6003E7A70 /* Geolocation.h in Headers */,
9746AF2514F4DDE6003E7A71 /* GeolocationClient.h in Headers */,
9746AF2714F4DDE6003E7A70 /* GeolocationController.h in Headers */,
Modified: trunk/Source/WebCore/animation/DocumentTimelinesController.cpp (278579 => 278580)
--- trunk/Source/WebCore/animation/DocumentTimelinesController.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/animation/DocumentTimelinesController.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -51,10 +51,7 @@
}
}
-DocumentTimelinesController::~DocumentTimelinesController()
-{
- m_currentTimeClearingTask.cancel();
-}
+DocumentTimelinesController::~DocumentTimelinesController() = default;
void DocumentTimelinesController::addTimeline(DocumentTimeline& timeline)
{
@@ -73,7 +70,7 @@
void DocumentTimelinesController::detachFromDocument()
{
- m_currentTimeClearingTask.cancel();
+ m_currentTimeClearingTaskCancellationGroup.cancel();
while (!m_timelines.computesEmpty())
m_timelines.begin()->detachFromDocument();
@@ -233,9 +230,8 @@
// animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
// fire syncronously if no JS is running.
m_waitingOnVMIdle = true;
- if (!m_currentTimeClearingTask.isPending()) {
- CancellableTask task(std::bind(&DocumentTimelinesController::maybeClearCachedCurrentTime, this));
- m_currentTimeClearingTask = task.createHandle();
+ if (!m_currentTimeClearingTaskCancellationGroup.hasPendingTask()) {
+ CancellableTask task(m_currentTimeClearingTaskCancellationGroup, std::bind(&DocumentTimelinesController::maybeClearCachedCurrentTime, this));
m_document.eventLoop().queueTask(TaskSource::InternalAsyncTask, WTFMove(task));
}
// We extent the associated Document's lifecycle until the VM became idle since the DocumentTimelinesController
@@ -252,7 +248,7 @@
// JS or waiting on all current animation updating code to have completed. This is so that
// we're guaranteed to have a consistent current time reported for all work happening in a given
// JS frame or throughout updating animations in WebCore.
- if (!m_isSuspended && !m_waitingOnVMIdle && !m_currentTimeClearingTask.isPending())
+ if (!m_isSuspended && !m_waitingOnVMIdle && !m_currentTimeClearingTaskCancellationGroup.hasPendingTask())
m_cachedCurrentTime = std::nullopt;
}
Modified: trunk/Source/WebCore/animation/DocumentTimelinesController.h (278579 => 278580)
--- trunk/Source/WebCore/animation/DocumentTimelinesController.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/animation/DocumentTimelinesController.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -67,7 +67,7 @@
void maybeClearCachedCurrentTime();
WeakHashSet<DocumentTimeline> m_timelines;
- CancellableTask::Handle m_currentTimeClearingTask;
+ TaskCancellationGroup m_currentTimeClearingTaskCancellationGroup;
Document& m_document;
Markable<Seconds, Seconds::MarkableTraits> m_cachedCurrentTime;
bool m_isSuspended { false };
Modified: trunk/Source/WebCore/dom/ActiveDOMObject.h (278579 => 278580)
--- trunk/Source/WebCore/dom/ActiveDOMObject.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/dom/ActiveDOMObject.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -112,14 +112,12 @@
}
template<typename T>
- static CancellableTask::Handle queueCancellableTaskKeepingObjectAlive(T& object, TaskSource source, Function<void()>&& task)
+ static void queueCancellableTaskKeepingObjectAlive(T& object, TaskSource source, TaskCancellationGroup& cancellationGroup, Function<void()>&& task)
{
- CancellableTask cancellableTask(WTFMove(task));
- auto taskHandle = cancellableTask.createHandle();
+ CancellableTask cancellableTask(cancellationGroup, WTFMove(task));
object.queueTaskInEventLoop(source, [protectedObject = makeRef(object), activity = object.ActiveDOMObject::makePendingActivity(object), cancellableTask = WTFMove(cancellableTask)]() mutable {
cancellableTask();
});
- return taskHandle;
}
template<typename EventTargetType, typename EventType>
Modified: trunk/Source/WebCore/dom/Document.h (278579 => 278580)
--- trunk/Source/WebCore/dom/Document.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/dom/Document.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -41,7 +41,6 @@
#include "FrameDestructionObserver.h"
#include "FrameIdentifier.h"
#include "FrameLoaderTypes.h"
-#include "GenericTaskQueue.h"
#include "GraphicsTypes.h"
#include "MediaProducer.h"
#include "MutationObserver.h"
Modified: trunk/Source/WebCore/dom/FullscreenManager.cpp (278579 => 278580)
--- trunk/Source/WebCore/dom/FullscreenManager.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/dom/FullscreenManager.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -30,6 +30,7 @@
#include "Chrome.h"
#include "ChromeClient.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Frame.h"
#include "HTMLIFrameElement.h"
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (278579 => 278580)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -394,7 +394,6 @@
, m_scanTimer(*this, &HTMLMediaElement::scanTimerFired)
, m_playbackControlsManagerBehaviorRestrictionsTimer(*this, &HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired)
, m_seekToPlaybackPositionEndedTimer(*this, &HTMLMediaElement::seekToPlaybackPositionEndedTimerFired)
- , m_resourceSelectionTaskQueue(&document)
, m_asyncEventQueue(EventLoopEventQueue::create(*this))
, m_lastTimeUpdateEventMovieTime(MediaTime::positiveInfiniteTime())
, m_firstTimePlaying(true)
@@ -567,11 +566,6 @@
if (m_isolatedWorld)
m_isolatedWorld->clearWrappers();
- m_seekTask.cancel();
- m_resumeTask.cancel();
- m_playbackControlsManagerBehaviorRestrictionsTask.cancel();
- m_resourceSelectionTaskQueue.close();
-
m_completelyLoaded = true;
if (m_player) {
@@ -893,9 +887,7 @@
void HTMLMediaElement::scheduleNextSourceChild()
{
// Schedule the timer to try the next <source> element WITHOUT resetting state ala prepareForLoad.
- m_resourceSelectionTaskQueue.enqueueTask([this] {
- loadNextSourceChild();
- });
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resourceSelectionTaskCancellationGroup, std::bind(&HTMLMediaElement::loadNextSourceChild, this));
}
void HTMLMediaElement::mediaPlayerActiveSourceBuffersChanged()
@@ -980,11 +972,11 @@
void HTMLMediaElement::scheduleCheckPlaybackTargetCompatability()
{
- if (m_checkPlaybackTargetCompatibilityTask.isPending())
+ if (m_checkPlaybackTargetCompatibilityTaskCancellationGroup.hasPendingTask())
return;
ALWAYS_LOG(LOGIDENTIFIER);
- m_checkPlaybackTargetCompatibilityTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_checkPlaybackTargetCompatibilityTaskCancellationGroup, [this] {
checkPlaybackTargetCompatibility();
});
}
@@ -1099,9 +1091,7 @@
return;
prepareForLoad();
- m_resourceSelectionTaskQueue.enqueueTask([this] {
- prepareToPlay();
- });
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resourceSelectionTaskCancellationGroup, std::bind(&HTMLMediaElement::prepareToPlay, this));
}
void HTMLMediaElement::prepareForLoad()
@@ -1118,7 +1108,7 @@
// 1 - Abort any already-running instance of the resource selection algorithm for this element.
// Perform the cleanup required for the resource load algorithm to run.
stopPeriodicTimers();
- m_resourceSelectionTaskQueue.cancelAllTasks();
+ m_resourceSelectionTaskCancellationGroup.cancel();
// FIXME: Figure out appropriate place to reset LoadTextTrackResource if necessary and set m_pendingActionFlags to 0 here.
m_sentEndEvent = false;
m_sentStalledEvent = false;
@@ -1230,17 +1220,14 @@
enterFullscreen(m_videoFullscreenMode);
if (previousMediaTime) {
- m_resourceSelectionTaskQueue.enqueueTask([this, previousMediaTime] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resourceSelectionTaskCancellationGroup, [this, previousMediaTime] {
if (m_player)
m_player->seekWhenPossible(previousMediaTime);
});
}
- if (!wasPaused) {
- m_resourceSelectionTaskQueue.enqueueTask([this] {
- playInternal();
- });
- }
+ if (!wasPaused)
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resourceSelectionTaskCancellationGroup, std::bind(&HTMLMediaElement::playInternal, this));
}
void HTMLMediaElement::selectMediaResource()
@@ -1258,7 +1245,7 @@
setShouldDelayLoadEvent(true);
// 4. in parallel await a stable state, allowing the task that invoked this algorithm to continue.
- if (m_resourceSelectionTaskQueue.hasPendingTasks())
+ if (m_resourceSelectionTaskCancellationGroup.hasPendingTask())
return;
if (!mediaSession().pageAllowsDataLoading()) {
@@ -1279,7 +1266,7 @@
auto logSiteIdentifier = LOGIDENTIFIER;
UNUSED_PARAM(logSiteIdentifier);
- m_resourceSelectionTaskQueue.enqueueTask([this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resourceSelectionTaskCancellationGroup, [this, logSiteIdentifier] {
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
@@ -2961,9 +2948,9 @@
// 3 - If the element's seeking IDL attribute is true, then another instance of this algorithm is
// already running. Abort that other instance of the algorithm without waiting for the step that
// it is running to complete.
- if (m_seekTask.isPending()) {
+ if (m_seekTaskCancellationGroup.hasPendingTask()) {
INFO_LOG(LOGIDENTIFIER, "cancelling pending seeks");
- m_seekTask.cancel();
+ m_seekTaskCancellationGroup.cancel();
if (m_pendingSeek) {
now = m_pendingSeek->now;
m_pendingSeek = nullptr;
@@ -2985,7 +2972,7 @@
m_pendingSeek = makeUnique<PendingSeek>(now, time, negativeTolerance, positiveTolerance);
if (fromDOM) {
INFO_LOG(LOGIDENTIFIER, "enqueuing seek from ", now, " to ", time);
- m_seekTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, std::bind(&HTMLMediaElement::seekTask, this));
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_seekTaskCancellationGroup, std::bind(&HTMLMediaElement::seekTask, this));
} else
seekTask();
@@ -3697,10 +3684,10 @@
auto oldVolume = m_volume;
m_volume = volume;
- if (m_volumeRevertTask.isPending())
+ if (m_volumeRevertTaskCancellationGroup.hasPendingTask())
return { };
- m_volumeRevertTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, oldVolume] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_volumeRevertTaskCancellationGroup, [this, oldVolume] {
m_volume = oldVolume;
});
@@ -4485,12 +4472,12 @@
void HTMLMediaElement::scheduleConfigureTextTracks()
{
- if (m_configureTextTracksTask.isPending())
+ if (m_configureTextTracksTaskCancellationGroup.hasPendingTask())
return;
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier, "task scheduled");
- m_configureTextTracksTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_configureTextTracksTaskCancellationGroup, [this, logSiteIdentifier] {
UNUSED_PARAM(logSiteIdentifier);
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
Ref<HTMLMediaElement> protectedThis(*this); // configureTextTracks calls methods that can trigger arbitrary DOM mutations.
@@ -5033,12 +5020,12 @@
void HTMLMediaElement::scheduleMediaEngineWasUpdated()
{
- if (m_mediaEngineUpdatedTask.isPending())
+ if (m_mediaEngineUpdatedTaskCancellationGroup.hasPendingTask())
return;
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier, "task scheduled");
- m_mediaEngineUpdatedTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_mediaEngineUpdatedTaskCancellationGroup, [this, logSiteIdentifier] {
UNUSED_PARAM(logSiteIdentifier);
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
Ref<HTMLMediaElement> protectedThis(*this); // mediaEngineWasUpdated calls methods that can trigger arbitrary DOM mutations.
@@ -5326,12 +5313,12 @@
void HTMLMediaElement::scheduleUpdatePlayState()
{
- if (m_updatePlayStateTask.isPending())
+ if (m_updatePlayStateTaskCancellationGroup.hasPendingTask())
return;
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier, "task scheduled");
- m_updatePlayStateTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_updatePlayStateTaskCancellationGroup, [this, logSiteIdentifier] {
UNUSED_PARAM(logSiteIdentifier);
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
Ref<HTMLMediaElement> protectedThis(*this); // updatePlayState calls methods that can trigger arbitrary DOM mutations.
@@ -5463,16 +5450,16 @@
void HTMLMediaElement::cancelPendingTasks()
{
- m_configureTextTracksTask.cancel();
- m_checkPlaybackTargetCompatibilityTask.cancel();
- m_updateMediaStateTask.cancel();
- m_mediaEngineUpdatedTask.cancel();
- m_updatePlayStateTask.cancel();
- m_resumeTask.cancel();
- m_seekTask.cancel();
- m_playbackControlsManagerBehaviorRestrictionsTask.cancel();
+ m_configureTextTracksTaskCancellationGroup.cancel();
+ m_checkPlaybackTargetCompatibilityTaskCancellationGroup.cancel();
+ m_updateMediaStateTaskCancellationGroup.cancel();
+ m_mediaEngineUpdatedTaskCancellationGroup.cancel();
+ m_updatePlayStateTaskCancellationGroup.cancel();
+ m_resumeTaskCancellationGroup.cancel();
+ m_seekTaskCancellationGroup.cancel();
+ m_playbackControlsManagerBehaviorRestrictionsTaskCancellationGroup.cancel();
#if PLATFORM(IOS_FAMILY)
- m_volumeRevertTask.cancel();
+ m_volumeRevertTaskCancellationGroup.cancel();
#endif
}
@@ -5587,7 +5574,7 @@
m_mediaSession->canProduceAudioChanged();
}
- m_resourceSelectionTaskQueue.cancelAllTasks();
+ m_resourceSelectionTaskCancellationGroup.cancel();
updateSleepDisabling();
}
@@ -5629,7 +5616,7 @@
void HTMLMediaElement::closeTaskQueues()
{
cancelPendingTasks();
- m_resourceSelectionTaskQueue.close();
+ m_resourceSelectionTaskCancellationGroup.cancel();
m_asyncEventQueue->close();
}
@@ -5664,7 +5651,7 @@
ALWAYS_LOG(LOGIDENTIFIER);
Ref<HTMLMediaElement> protectedThis(*this);
- m_resumeTask.cancel();
+ m_resumeTaskCancellationGroup.cancel();
switch (reason) {
case ReasonForSuspension::BackForwardCache:
@@ -5697,13 +5684,13 @@
m_mediaSession->updateBufferingPolicy();
}
- if (m_error && m_error->code() == MediaError::MEDIA_ERR_ABORTED && !m_resumeTask.isPending()) {
+ if (m_error && m_error->code() == MediaError::MEDIA_ERR_ABORTED && !m_resumeTaskCancellationGroup.hasPendingTask()) {
// Restart the load if it was aborted in the middle by moving the document to the back/forward cache.
// m_error is only left at MEDIA_ERR_ABORTED when the document becomes inactive (it is set to
// MEDIA_ERR_ABORTED while the abortEvent is being sent, but cleared immediately afterwards).
// This behavior is not specified but it seems like a sensible thing to do.
// As it is not safe to immedately start loading now, let's schedule a load.
- m_resumeTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, std::bind(&HTMLMediaElement::prepareForLoad, this));
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_resumeTaskCancellationGroup, std::bind(&HTMLMediaElement::prepareForLoad, this));
}
updateRenderer();
@@ -5719,7 +5706,6 @@
{
return m_creatingControls
|| m_asyncEventQueue->hasPendingActivity()
- || m_resourceSelectionTaskQueue.hasPendingTasks()
|| (hasAudio() && isPlaying())
|| (hasLiveSource() && hasEventListeners());
}
@@ -6615,7 +6601,7 @@
}
m_processingPreferenceChange = true;
- m_configureTextTracksTask.cancel();
+ m_configureTextTracksTaskCancellationGroup.cancel();
if (mode == Immediately) {
Ref<HTMLMediaElement> protectedThis(*this); // configureTextTracks calls methods that can trigger arbitrary DOM mutations.
configureTextTracks();
@@ -7131,12 +7117,12 @@
void HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged()
{
- if (!m_textTracks || m_bufferedTimeRangesChangedTask.isPending())
+ if (!m_textTracks || m_bufferedTimeRangesChangedTaskCancellationGroup.hasPendingTask())
return;
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier, "task scheduled");
- m_bufferedTimeRangesChangedTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_bufferedTimeRangesChangedTaskCancellationGroup, [this, logSiteIdentifier] {
UNUSED_PARAM(logSiteIdentifier);
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
if (!m_player || !m_textTracks)
@@ -7762,12 +7748,12 @@
void HTMLMediaElement::scheduleUpdateMediaState()
{
- if (m_updateMediaStateTask.isPending())
+ if (m_updateMediaStateTaskCancellationGroup.hasPendingTask())
return;
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier, "task scheduled");
- m_updateMediaStateTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this, logSiteIdentifier] {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_updateMediaStateTaskCancellationGroup, [this, logSiteIdentifier] {
UNUSED_PARAM(logSiteIdentifier);
ALWAYS_LOG(logSiteIdentifier, "lambda(), task fired");
Ref<HTMLMediaElement> protectedThis(*this); // updateMediaState calls methods that can trigger arbitrary DOM mutations.
@@ -8035,13 +8021,13 @@
void HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired()
{
- if (m_playbackControlsManagerBehaviorRestrictionsTask.isPending())
+ if (m_playbackControlsManagerBehaviorRestrictionsTaskCancellationGroup.hasPendingTask())
return;
if (!mediaSession().hasBehaviorRestriction(MediaElementSession::RequireUserGestureToControlControlsManager))
return;
- m_playbackControlsManagerBehaviorRestrictionsTask = queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, [this] () {
+ queueCancellableTaskKeepingObjectAlive(*this, TaskSource::MediaElement, m_playbackControlsManagerBehaviorRestrictionsTaskCancellationGroup, [this] () {
auto& mediaElementSession = mediaSession();
if (isPlaying() || mediaElementSession.state() == PlatformMediaSession::Autoplaying || mediaElementSession.state() == PlatformMediaSession::Playing)
return;
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (278579 => 278580)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -940,20 +940,20 @@
Timer m_scanTimer;
Timer m_playbackControlsManagerBehaviorRestrictionsTimer;
Timer m_seekToPlaybackPositionEndedTimer;
- CancellableTask::Handle m_configureTextTracksTask;
- CancellableTask::Handle m_checkPlaybackTargetCompatibilityTask;
- CancellableTask::Handle m_updateMediaStateTask;
- CancellableTask::Handle m_mediaEngineUpdatedTask;
- CancellableTask::Handle m_updatePlayStateTask;
- CancellableTask::Handle m_resumeTask;
- CancellableTask::Handle m_seekTask;
- CancellableTask::Handle m_playbackControlsManagerBehaviorRestrictionsTask;
- CancellableTask::Handle m_bufferedTimeRangesChangedTask;
- EventLoopTaskQueue m_resourceSelectionTaskQueue;
+ TaskCancellationGroup m_configureTextTracksTaskCancellationGroup;
+ TaskCancellationGroup m_checkPlaybackTargetCompatibilityTaskCancellationGroup;
+ TaskCancellationGroup m_updateMediaStateTaskCancellationGroup;
+ TaskCancellationGroup m_mediaEngineUpdatedTaskCancellationGroup;
+ TaskCancellationGroup m_updatePlayStateTaskCancellationGroup;
+ TaskCancellationGroup m_resumeTaskCancellationGroup;
+ TaskCancellationGroup m_seekTaskCancellationGroup;
+ TaskCancellationGroup m_playbackControlsManagerBehaviorRestrictionsTaskCancellationGroup;
+ TaskCancellationGroup m_bufferedTimeRangesChangedTaskCancellationGroup;
+ TaskCancellationGroup m_resourceSelectionTaskCancellationGroup;
RefPtr<TimeRanges> m_playedTimeRanges;
UniqueRef<EventLoopEventQueue> m_asyncEventQueue;
#if PLATFORM(IOS_FAMILY)
- CancellableTask::Handle m_volumeRevertTask;
+ TaskCancellationGroup m_volumeRevertTaskCancellationGroup;
#endif
PlayPromiseVector m_pendingPlayPromises;
Modified: trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp (278579 => 278580)
--- trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp 2021-06-08 00:29:50 UTC (rev 278580)
@@ -35,6 +35,7 @@
#include "DOMTokenList.h"
#include "ElementChildIterator.h"
#include "EventHandler.h"
+#include "EventLoop.h"
#include "EventNames.h"
#include "Frame.h"
#include "FullscreenManager.h"
Deleted: trunk/Source/WebCore/platform/GenericTaskQueue.h (278579 => 278580)
--- trunk/Source/WebCore/platform/GenericTaskQueue.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/platform/GenericTaskQueue.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "ContextDestructionObserver.h"
-#include "EventLoop.h"
-#include "ScriptExecutionContext.h"
-#include <wtf/Function.h>
-#include <wtf/MainThread.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class TaskQueueBase : public CanMakeWeakPtr<TaskQueueBase> {
- WTF_MAKE_FAST_ALLOCATED;
-public:
- bool hasPendingTasks() const { return m_pendingTasks; }
- bool isClosed() const { return m_isClosed; }
-
- void close()
- {
- cancelAllTasks();
- m_isClosed = true;
- }
-
- void cancelAllTasks()
- {
- weakPtrFactory().revokeAll();
- m_pendingTasks = 0;
- }
-
-protected:
- ~TaskQueueBase() = default;
- void incrementPendingTasks() { ++m_pendingTasks; }
- void decrementPendingTasks() { ASSERT(m_pendingTasks); --m_pendingTasks; }
-
-private:
- unsigned m_pendingTasks { 0 };
- bool m_isClosed { false };
-};
-
-// Relies on a shared Timer, only safe to use on the MainThread. Please use EventLoopTaskQueue
-// (or dispatch directly to the HTML event loop) whenever possible.
-class MainThreadTaskQueue : public TaskQueueBase {
-public:
- MainThreadTaskQueue()
- {
- ASSERT(isMainThread());
- }
-
- void enqueueTask(Function<void()>&& task)
- {
- if (isClosed())
- return;
-
- incrementPendingTasks();
- callOnMainThread([weakThis = makeWeakPtr(*this), task = WTFMove(task)] {
- if (!weakThis)
- return;
- weakThis->decrementPendingTasks();
- task();
- });
- }
-};
-
-// Similar to MainThreadTaskQueue but based on the HTML event loop.
-class EventLoopTaskQueue : public TaskQueueBase, private ContextDestructionObserver {
-public:
- EventLoopTaskQueue(ScriptExecutionContext* context)
- : ContextDestructionObserver(context)
- { }
-
- // FIXME: Pass a TaskSource instead of assuming TaskSource::MediaElement.
- void enqueueTask(Function<void()>&& task)
- {
- if (isClosed() || !scriptExecutionContext())
- return;
-
- incrementPendingTasks();
- scriptExecutionContext()->eventLoop().queueTask(TaskSource::MediaElement, [weakThis = makeWeakPtr(*this), task = WTFMove(task)] {
- if (!weakThis)
- return;
- weakThis->decrementPendingTasks();
- task();
- });
- }
-};
-
-}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (278579 => 278580)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2021-06-08 00:29:50 UTC (rev 278580)
@@ -173,7 +173,6 @@
@interface WebCoreAVFMovieObserver : NSObject <AVPlayerItemLegibleOutputPushDelegate, AVPlayerItemMetadataOutputPushDelegate, AVPlayerItemMetadataCollectorPushDelegate>
{
WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_player;
- MainThreadTaskQueue m_taskQueue;
int m_delayCallbacks;
}
-(id)initWithPlayer:(WeakPtr<MediaPlayerPrivateAVFoundationObjC>&&)callback;
@@ -189,7 +188,6 @@
@interface WebCoreAVFLoaderDelegate : NSObject<AVAssetResourceLoaderDelegate> {
WeakPtr<MediaPlayerPrivateAVFoundationObjC> m_player;
- MainThreadTaskQueue m_taskQueue;
}
- (id)initWithPlayer:(WeakPtr<MediaPlayerPrivateAVFoundationObjC>&&)player;
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest;
@@ -3580,7 +3578,7 @@
- (void)metadataLoaded
{
ensureOnMainThread([self, strongSelf = retainPtr(self)] {
- m_taskQueue.enqueueTask([player = m_player] {
+ callOnMainThread([player = m_player] {
if (player)
player->metadataLoaded();
});
@@ -3591,7 +3589,7 @@
{
UNUSED_PARAM(unusedNotification);
ensureOnMainThread([self, strongSelf = retainPtr(self)] {
- m_taskQueue.enqueueTask([player = m_player] {
+ callOnMainThread([player = m_player] {
if (player)
player->didEnd();
});
@@ -3601,7 +3599,7 @@
- (void)observeValueForKeyPath:keyPath ofObject:(id)object change:(NSDictionary *)change context:(MediaPlayerAVFoundationObservationContext)context
{
ensureOnMainThread([self, strongSelf = retainPtr(self), keyPath = retainPtr(keyPath), change = retainPtr(change), object = retainPtr(object), context]() mutable {
- m_taskQueue.enqueueTask([player = m_player, keyPath = WTFMove(keyPath), change = WTFMove(change), object = WTFMove(object), context] {
+ callOnMainThread([player = m_player, keyPath = WTFMove(keyPath), change = WTFMove(change), object = WTFMove(object), context] {
if (!player)
return;
@@ -3700,7 +3698,7 @@
UNUSED_PARAM(output);
ensureOnMainThread([self, strongSelf = retainPtr(self), strings = retainPtr(strings), nativeSamples = retainPtr(nativeSamples), itemTime]() mutable {
- m_taskQueue.enqueueTask([player = m_player, strings = WTFMove(strings), nativeSamples = WTFMove(nativeSamples), itemTime] {
+ callOnMainThread([player = m_player, strings = WTFMove(strings), nativeSamples = WTFMove(nativeSamples), itemTime] {
if (!player)
return;
@@ -3717,7 +3715,7 @@
UNUSED_PARAM(output);
ensureOnMainThread([self, strongSelf = retainPtr(self)] {
- m_taskQueue.enqueueTask([player = m_player] {
+ callOnMainThread([player = m_player] {
if (player)
player->flushCues();
});
@@ -3733,7 +3731,7 @@
if (!m_player || !metadataGroups)
return;
- m_taskQueue.enqueueTask([player = m_player, metadataGroups = retainPtr(metadataGroups), currentTime = m_player->currentMediaTime()] {
+ callOnMainThread([player = m_player, metadataGroups = retainPtr(metadataGroups), currentTime = m_player->currentMediaTime()] {
if (!player)
return;
@@ -3754,7 +3752,7 @@
if (!m_player || !metadataGroups)
return;
- m_taskQueue.enqueueTask([player = m_player, metadataGroups = retainPtr(metadataGroups), currentTime = m_player->currentMediaTime()] {
+ callOnMainThread([player = m_player, metadataGroups = retainPtr(metadataGroups), currentTime = m_player->currentMediaTime()] {
if (!player)
return;
@@ -3781,7 +3779,7 @@
return NO;
ensureOnMainThread([self, strongSelf = retainPtr(self), loadingRequest = retainPtr(loadingRequest)]() mutable {
- m_taskQueue.enqueueTask([player = m_player, loadingRequest = WTFMove(loadingRequest)] {
+ callOnMainThread([player = m_player, loadingRequest = WTFMove(loadingRequest)] {
if (!player) {
[loadingRequest finishLoadingWithError:nil];
return;
@@ -3807,7 +3805,7 @@
{
UNUSED_PARAM(resourceLoader);
ensureOnMainThread([self, strongSelf = retainPtr(self), loadingRequest = retainPtr(loadingRequest)]() mutable {
- m_taskQueue.enqueueTask([player = m_player, loadingRequest = WTFMove(loadingRequest)] {
+ callOnMainThread([player = m_player, loadingRequest = WTFMove(loadingRequest)] {
ScriptDisallowedScope::InMainThread scriptDisallowedScope;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (278579 => 278580)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -27,11 +27,11 @@
#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
-#include "GenericTaskQueue.h"
#include "SourceBufferParser.h"
#include "SourceBufferPrivate.h"
#include <dispatch/group.h>
#include <wtf/Box.h>
+#include <wtf/CancellableTask.h>
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/LoggerHelper.h>
@@ -193,7 +193,7 @@
bool m_initializationSegmentIsHandled { false };
bool m_hasPendingAppendCompletedCallback { false };
Vector<std::pair<uint64_t, Ref<MediaSample>>> m_mediaSamples;
- MainThreadTaskQueue m_mediaSampleTaskQueue;
+ TaskCancellationGroup m_mediaSampleTaskCancellationGroup;
RetainPtr<AVSampleBufferDisplayLayer> m_displayLayer;
ALLOW_NEW_API_WITHOUT_GUARDS_BEGIN
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (278579 => 278580)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2021-06-08 00:29:50 UTC (rev 278580)
@@ -359,7 +359,7 @@
if (m_hasSessionSemaphore)
m_hasSessionSemaphore->signal();
- m_mediaSampleTaskQueue.close();
+ m_mediaSampleTaskCancellationGroup.cancel();
}
void SourceBufferPrivateAVFObjC::didParseInitializationData(InitializationSegment&& segment)
@@ -418,7 +418,7 @@
return;
}
- m_mediaSampleTaskQueue.enqueueTask([this, weakThis = WTFMove(weakThis)] {
+ callOnMainThread(CancellableTask(m_mediaSampleTaskCancellationGroup, [this, weakThis = WTFMove(weakThis)] {
if (!weakThis)
return;
@@ -439,7 +439,7 @@
m_hasPendingAppendCompletedCallback = false;
appendCompleted();
}
- });
+ }));
});
}
@@ -676,7 +676,7 @@
m_parser->resetParserState();
m_mediaSamples.clear();
m_initializationSegmentIsHandled = false;
- m_mediaSampleTaskQueue.cancelAllTasks();
+ m_mediaSampleTaskCancellationGroup.cancel();
dispatch_group_wait(m_isAppendingGroup.get(), DISPATCH_TIME_FOREVER);
}
Modified: trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h (278579 => 278580)
--- trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h 2021-06-08 00:05:14 UTC (rev 278579)
+++ trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h 2021-06-08 00:29:50 UTC (rev 278580)
@@ -28,7 +28,6 @@
#if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
#include "CaptureDeviceManager.h"
-#include "GenericTaskQueue.h"
#include <wtf/Lock.h>
#include <wtf/RetainPtr.h>
#include <wtf/WorkQueue.h>