author | Jean-Yves Avenard <jyavenard@mozilla.com> |
Mon, 12 Nov 2018 01:09:03 +0000 | |
changeset 445874 | 6f08cc82afe3280863c897dda1e141d8c4c165d7 |
parent 445873 | 1dab4c7062aeae80016ca8043a752271b6ab8a94 |
child 445875 | bcf48a8dba79f51f291e476053fab60e6586c9f3 |
push id | 109795 |
push user | rmaries@mozilla.com |
push date | Mon, 12 Nov 2018 17:23:23 +0000 |
treeherder | mozilla-inbound@ccc0ff898ca2 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cpearce |
bugs | 1505910 |
milestone | 65.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/Benchmark.cpp +++ b/dom/media/Benchmark.cpp @@ -294,20 +294,18 @@ BenchmarkPlayback::FinalizeShutdown() if (mTrackDemuxer) { mTrackDemuxer->Reset(); mTrackDemuxer->BreakCycles(); mTrackDemuxer = nullptr; } mDemuxer = nullptr; RefPtr<Benchmark> ref(mGlobalState); - Thread()->AsTaskQueue()->BeginShutdown()->Then( - ref->Thread(), __func__, - [ref]() { ref->Dispose(); }, - []() { MOZ_CRASH("not reached"); }); + ref->Thread()->Dispatch(NS_NewRunnableFunction( + "BenchmarkPlayback::FinalizeShutdown", [ref]() { ref->Dispose(); })); } void BenchmarkPlayback::GlobalShutdown() { MOZ_ASSERT(OnThread()); MOZ_ASSERT(!mFinished, "We've already shutdown");
--- a/dom/media/mediasource/SourceBufferResource.cpp +++ b/dom/media/mediasource/SourceBufferResource.cpp @@ -29,17 +29,17 @@ mozilla::LogModule* GetSourceBufferResou __func__, \ ##__VA_ARGS__) namespace mozilla { nsresult SourceBufferResource::Close() { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG("Close"); mClosed = true; return NS_OK; } nsresult SourceBufferResource::ReadAt(int64_t aOffset, char* aBuffer, @@ -52,17 +52,17 @@ SourceBufferResource::ReadAt(int64_t aOf } nsresult SourceBufferResource::ReadAtInternal(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes) { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); if (mClosed || aOffset < 0 || uint64_t(aOffset) < mInputBuffer.GetOffset() || aOffset > GetLength()) { return NS_ERROR_FAILURE; } @@ -103,79 +103,79 @@ SourceBufferResource::ReadFromCache(char return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE; } uint32_t SourceBufferResource::EvictData(uint64_t aPlaybackOffset, int64_t aThreshold, ErrorResult& aRv) { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG("EvictData(aPlaybackOffset=%" PRIu64 "," "aThreshold=%" PRId64 ")", aPlaybackOffset, aThreshold); uint32_t result = mInputBuffer.Evict(aPlaybackOffset, aThreshold, aRv); return result; } void SourceBufferResource::EvictBefore(uint64_t aOffset, ErrorResult& aRv) { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG("EvictBefore(aOffset=%" PRIu64 ")", aOffset); mInputBuffer.EvictBefore(aOffset, aRv); } uint32_t SourceBufferResource::EvictAll() { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG("EvictAll()"); return mInputBuffer.EvictAll(); } void SourceBufferResource::AppendData(MediaByteBuffer* aData) { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG("AppendData(aData=%p, aLength=%zu)", aData->Elements(), aData->Length()); mInputBuffer.AppendItem(aData); mEnded = false; } void SourceBufferResource::Ended() { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); SBR_DEBUG(""); mEnded = true; } SourceBufferResource::~SourceBufferResource() { SBR_DEBUG(""); } SourceBufferResource::SourceBufferResource() #if defined(DEBUG) - : mTaskQueue(AbstractThread::GetCurrent()->AsTaskQueue()) + : mThread(AbstractThread::GetCurrent()) #endif { SBR_DEBUG(""); } #if defined(DEBUG) -AbstractThread* -SourceBufferResource::GetTaskQueue() const +const AbstractThread* +SourceBufferResource::GetThread() const { - return mTaskQueue; + return mThread; } bool -SourceBufferResource::OnTaskQueue() const +SourceBufferResource::OnThread() const { - return !GetTaskQueue() || GetTaskQueue()->IsCurrentThreadIn(); + return !GetThread() || GetThread()->IsCurrentThreadIn(); } #endif #undef SBR_DEBUG #undef SBR_DEBUGV } // namespace mozilla
--- a/dom/media/mediasource/SourceBufferResource.h +++ b/dom/media/mediasource/SourceBufferResource.h @@ -13,17 +13,17 @@ #include "nsIPrincipal.h" #include "ResourceQueue.h" #define UNIMPLEMENTED() { /* Logging this is too spammy to do by default */ } namespace mozilla { class MediaByteBuffer; -class TaskQueue; +class AbstractThread; namespace dom { class SourceBuffer; } // namespace dom DDLoggedTypeDeclNameAndBase(SourceBufferResource, MediaResource); @@ -42,85 +42,85 @@ public: uint32_t* aBytes) override; // Memory-based and no locks, caching discouraged. bool ShouldCacheReads() override { return false; } void Pin() override { UNIMPLEMENTED(); } void Unpin() override { UNIMPLEMENTED(); } int64_t GetLength() override { return mInputBuffer.GetLength(); } int64_t GetNextCachedData(int64_t aOffset) override { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); MOZ_ASSERT(aOffset >= 0); if (uint64_t(aOffset) < mInputBuffer.GetOffset()) { return mInputBuffer.GetOffset(); } else if (aOffset == GetLength()) { return -1; } return aOffset; } int64_t GetCachedDataEnd(int64_t aOffset) override { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); MOZ_ASSERT(aOffset >= 0); if (uint64_t(aOffset) < mInputBuffer.GetOffset() || aOffset >= GetLength()) { // aOffset is outside of the buffered range. return aOffset; } return GetLength(); } bool IsDataCachedToEndOfResource(int64_t aOffset) override { return false; } nsresult ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCount) override; nsresult GetCachedRanges(MediaByteRangeSet& aRanges) override { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); if (mInputBuffer.GetLength()) { aRanges += MediaByteRange(mInputBuffer.GetOffset(), mInputBuffer.GetLength()); } return NS_OK; } size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); return mInputBuffer.SizeOfExcludingThis(aMallocSizeOf); } size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } // Used by SourceBuffer. void AppendData(MediaByteBuffer* aData); void Ended(); bool IsEnded() { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); return mEnded; } // Remove data from resource if it holds more than the threshold reduced by // the given number of bytes. Returns amount evicted. uint32_t EvictData(uint64_t aPlaybackOffset, int64_t aThresholdReduct, ErrorResult& aRv); // Remove data from resource before the given offset. void EvictBefore(uint64_t aOffset, ErrorResult& aRv); // Remove all data from the resource uint32_t EvictAll(); // Returns the amount of data currently retained by this resource. int64_t GetSize() { - MOZ_ASSERT(OnTaskQueue()); + MOZ_ASSERT(OnThread()); return mInputBuffer.GetLength() - mInputBuffer.GetOffset(); } #if defined(DEBUG) void Dump(const char* aPath) { mInputBuffer.Dump(aPath); } @@ -129,20 +129,20 @@ public: private: virtual ~SourceBufferResource(); nsresult ReadAtInternal(int64_t aOffset, char* aBuffer, uint32_t aCount, uint32_t* aBytes); #if defined(DEBUG) - const RefPtr<TaskQueue> mTaskQueue; + const RefPtr<AbstractThread> mThread; // TaskQueue methods and objects. - AbstractThread* GetTaskQueue() const; - bool OnTaskQueue() const; + const AbstractThread* GetThread() const; + bool OnThread() const; #endif // The buffer holding resource data. ResourceQueue mInputBuffer; bool mClosed = false; bool mEnded = false; };
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp @@ -306,55 +306,55 @@ private: bool mIsShutdown; }; EMEMediaDataDecoderProxy::EMEMediaDataDecoderProxy( already_AddRefed<AbstractThread> aProxyThread, CDMProxy* aProxy, const CreateDecoderParams& aParams) : MediaDataDecoderProxy(std::move(aProxyThread)) - , mTaskQueue(AbstractThread::GetCurrent()->AsTaskQueue()) + , mThread(AbstractThread::GetCurrent()) , mSamplesWaitingForKey( new SamplesWaitingForKey(aProxy, aParams.mType, aParams.mOnWaitingForKeyEvent)) , mProxy(aProxy) { } EMEMediaDataDecoderProxy::EMEMediaDataDecoderProxy( const CreateDecoderParams& aParams, already_AddRefed<MediaDataDecoder> aProxyDecoder, CDMProxy* aProxy) : MediaDataDecoderProxy(std::move(aProxyDecoder)) - , mTaskQueue(AbstractThread::GetCurrent()->AsTaskQueue()) + , mThread(AbstractThread::GetCurrent()) , mSamplesWaitingForKey( new SamplesWaitingForKey(aProxy, aParams.mType, aParams.mOnWaitingForKeyEvent)) , mProxy(aProxy) { } RefPtr<MediaDataDecoder::DecodePromise> EMEMediaDataDecoderProxy::Decode(MediaRawData* aSample) { RefPtr<EMEMediaDataDecoderProxy> self = this; RefPtr<MediaRawData> sample = aSample; - return InvokeAsync(mTaskQueue, __func__, [self, this, sample]() { + return InvokeAsync(mThread, __func__, [self, this, sample]() { RefPtr<DecodePromise> p = mDecodePromise.Ensure(__func__); mSamplesWaitingForKey->WaitIfKeyNotUsable(sample) - ->Then(mTaskQueue, + ->Then(mThread, __func__, [self, this](RefPtr<MediaRawData> aSample) { mKeyRequest.Complete(); MediaDataDecoderProxy::Decode(aSample) ->Then( - mTaskQueue, + mThread, __func__, [self, this](DecodePromise::ResolveOrRejectValue&& aValue) { mDecodeRequest.Complete(); mDecodePromise.ResolveOrReject(std::move(aValue), __func__); }) ->Track(mDecodeRequest); }, @@ -367,29 +367,29 @@ EMEMediaDataDecoderProxy::Decode(MediaRa return p; }); } RefPtr<MediaDataDecoder::FlushPromise> EMEMediaDataDecoderProxy::Flush() { RefPtr<EMEMediaDataDecoderProxy> self = this; - return InvokeAsync(mTaskQueue, __func__, [self, this]() { + return InvokeAsync(mThread, __func__, [self, this]() { mKeyRequest.DisconnectIfExists(); mDecodeRequest.DisconnectIfExists(); mDecodePromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__); return MediaDataDecoderProxy::Flush(); }); } RefPtr<ShutdownPromise> EMEMediaDataDecoderProxy::Shutdown() { RefPtr<EMEMediaDataDecoderProxy> self = this; - return InvokeAsync(mTaskQueue, __func__, [self, this]() { + return InvokeAsync(mThread, __func__, [self, this]() { mSamplesWaitingForKey = nullptr; mProxy = nullptr; return MediaDataDecoderProxy::Shutdown(); }); } EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM) : mProxy(aProxy)
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.h +++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.h @@ -56,17 +56,17 @@ public: already_AddRefed<MediaDataDecoder> aProxyDecoder, CDMProxy* aProxy); RefPtr<DecodePromise> Decode(MediaRawData* aSample) override; RefPtr<FlushPromise> Flush() override; RefPtr<ShutdownPromise> Shutdown() override; private: - RefPtr<TaskQueue> mTaskQueue; + RefPtr<AbstractThread> mThread; RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey; MozPromiseRequestHolder<SamplesWaitingForKey::WaitForKeyPromise> mKeyRequest; MozPromiseHolder<DecodePromise> mDecodePromise; MozPromiseRequestHolder<DecodePromise> mDecodeRequest; RefPtr<CDMProxy> mProxy; }; } // namespace mozilla
--- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -562,17 +562,17 @@ MediaChangeMonitor::DecodeFirstSample(Me mDecodePromise.Reject(rv, __func__); return; } mNeedKeyframe = false; RefPtr<MediaChangeMonitor> self = this; mDecoder->Decode(aSample) - ->Then(AbstractThread::GetCurrent()->AsTaskQueue(), __func__, + ->Then(mTaskQueue, __func__, [self, this](MediaDataDecoder::DecodedData&& aResults) { mDecodePromiseRequest.Complete(); mPendingFrames.AppendElements(std::move(aResults)); mDecodePromise.Resolve(std::move(mPendingFrames), __func__); mPendingFrames = DecodedData(); }, [self, this](const MediaResult& aError) { mDecodePromiseRequest.Complete(); @@ -611,17 +611,17 @@ MediaChangeMonitor::CheckForChange(Media void MediaChangeMonitor::DrainThenFlushDecoder(MediaRawData* aPendingSample) { AssertOnTaskQueue(); RefPtr<MediaRawData> sample = aPendingSample; RefPtr<MediaChangeMonitor> self = this; mDecoder->Drain() - ->Then(AbstractThread::GetCurrent()->AsTaskQueue(), + ->Then(mTaskQueue, __func__, [self, sample, this](MediaDataDecoder::DecodedData&& aResults) { mDrainRequest.Complete(); if (!mFlushPromise.IsEmpty()) { // A Flush is pending, abort the current operation. mFlushPromise.Resolve(true, __func__); return; }
--- a/xpcom/threads/AbstractThread.cpp +++ b/xpcom/threads/AbstractThread.cpp @@ -56,17 +56,17 @@ public: RefPtr<nsIRunnable> runner(new Runner(this, std::move(aRunnable), false /* already drained by TaskGroupRunnable */)); return mTarget->Dispatch(runner.forget(), NS_DISPATCH_NORMAL); } // Prevent a GCC warning about the other overload of Dispatch being hidden. using AbstractThread::Dispatch; - virtual bool IsCurrentThreadIn() override + virtual bool IsCurrentThreadIn() const override { return mTarget->IsOnCurrentThread(); } void FireTailDispatcher() { AutoEnter context(this);
--- a/xpcom/threads/AbstractThread.h +++ b/xpcom/threads/AbstractThread.h @@ -69,17 +69,17 @@ public: NS_IMETHOD Dispatch(already_AddRefed<nsIRunnable> event, uint32_t flags) override; NS_IMETHOD DispatchFromScript(nsIRunnable *event, uint32_t flags) override; NS_IMETHOD DelayedDispatch(already_AddRefed<nsIRunnable> event, uint32_t delay) override; enum DispatchReason { NormalDispatch, TailDispatch }; virtual nsresult Dispatch(already_AddRefed<nsIRunnable> aRunnable, DispatchReason aReason = NormalDispatch) = 0; - virtual bool IsCurrentThreadIn() = 0; + virtual bool IsCurrentThreadIn() const = 0; // Returns a TaskDispatcher that will dispatch its tasks when the currently- // running tasks pops off the stack. // // May only be called when running within the it is invoked up, and only on // threads which support it. virtual TaskDispatcher& TailDispatcher() = 0;
--- a/xpcom/threads/TaskQueue.cpp +++ b/xpcom/threads/TaskQueue.cpp @@ -189,17 +189,17 @@ TaskQueue::BeginShutdown() bool TaskQueue::IsEmpty() { MonitorAutoLock mon(mQueueMonitor); return mTasks.empty(); } bool -TaskQueue::IsCurrentThreadIn() +TaskQueue::IsCurrentThreadIn() const { bool in = mRunningThread == GetCurrentPhysicalThread(); return in; } already_AddRefed<nsISerialEventTarget> TaskQueue::WrapAsEventTarget() {
--- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -97,17 +97,17 @@ public: // Blocks until the queue is flagged for shutdown and all tasks have finished // executing. void AwaitShutdownAndIdle(); bool IsEmpty(); // Returns true if the current thread is currently running a Runnable in // the task queue. - bool IsCurrentThreadIn() override; + bool IsCurrentThreadIn() const override; // Create a new nsIEventTarget wrapper object that dispatches to this // TaskQueue. already_AddRefed<nsISerialEventTarget> WrapAsEventTarget(); protected: virtual ~TaskQueue();