From cf648225272b6a2e205e956d7792179560511c89 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Fri, 1 Mar 2019 15:11:56 +0200 Subject: [PATCH] Bug 1519567, use medium high priority queue for imglib notifications, r=tnikkel --HG-- extra : rebase_source : e78679b1bec411508291c7ce5f9c2600d1fe5c90 --- image/IDecodingTask.cpp | 22 +++++++++++----------- image/Image.cpp | 3 ++- image/VectorImage.cpp | 7 ++++--- image/imgRequestProxy.cpp | 8 +++++--- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/image/IDecodingTask.cpp b/image/IDecodingTask.cpp index 3d7b5a4c94ee..2b8f641bcdf4 100644 --- a/image/IDecodingTask.cpp +++ b/image/IDecodingTask.cpp @@ -82,13 +82,13 @@ void IDecodingTask::NotifyProgress(NotNull aImage, // We're forced to notify asynchronously. NotNull> image = aImage; - mEventTarget->Dispatch(NS_NewRunnableFunction("IDecodingTask::NotifyProgress", - [=]() -> void { - image->NotifyProgress( - progress, invalidRect, - frameCount, decoderFlags, - surfaceFlags); - }), + mEventTarget->Dispatch(CreateMediumHighRunnable(NS_NewRunnableFunction( + "IDecodingTask::NotifyProgress", + [=]() -> void { + image->NotifyProgress(progress, invalidRect, + frameCount, decoderFlags, + surfaceFlags); + })), NS_DISPATCH_NORMAL); } @@ -118,15 +118,15 @@ void IDecodingTask::NotifyDecodeComplete(NotNull aImage, // We're forced to notify asynchronously. NotNull> image = aImage; - mEventTarget->Dispatch( - NS_NewRunnableFunction("IDecodingTask::NotifyDecodeComplete", + mEventTarget->Dispatch(CreateMediumHighRunnable(NS_NewRunnableFunction( + "IDecodingTask::NotifyDecodeComplete", [=]() -> void { image->NotifyDecodeComplete( finalStatus, metadata, telemetry, progress, invalidRect, frameCount, decoderFlags, surfaceFlags); - }), - NS_DISPATCH_NORMAL); + })), + NS_DISPATCH_NORMAL); } /////////////////////////////////////////////////////////////////////////////// diff --git a/image/Image.cpp b/image/Image.cpp index dfdf09b71920..d5c875f190eb 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -400,7 +400,8 @@ void ImageResource::SendOnUnlockedDraw(uint32_t aFlags) { tracker->OnUnlockedDraw(); } }); - eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL); + eventTarget->Dispatch(CreateMediumHighRunnable(ev.forget()), + NS_DISPATCH_NORMAL); } } diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 569824c74aaa..675b02d064d8 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -1180,14 +1180,14 @@ void VectorImage::SendFrameComplete(bool aDidCache, uint32_t aFlags) { GetMaxSizedIntRect()); } else { NotNull> image = WrapNotNull(this); - NS_DispatchToMainThread(NS_NewRunnableFunction( + NS_DispatchToMainThread(CreateMediumHighRunnable(NS_NewRunnableFunction( "ProgressTracker::SyncNotifyProgress", [=]() -> void { RefPtr tracker = image->GetProgressTracker(); if (tracker) { tracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE, GetMaxSizedIntRect()); } - })); + }))); } } @@ -1513,7 +1513,8 @@ void VectorImage::InvalidateObserversOnNextRefreshDriverTick() { nsCOMPtr ev(NS_NewRunnableFunction( "VectorImage::SendInvalidationNotifications", [=]() -> void { self->SendInvalidationNotifications(); })); - eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL); + eventTarget->Dispatch(CreateMediumHighRunnable(ev.forget()), + NS_DISPATCH_NORMAL); } void VectorImage::PropagateUseCounters(Document* aParentDocument) { diff --git a/image/imgRequestProxy.cpp b/image/imgRequestProxy.cpp index 55d0b077c412..fc35b3cd47c6 100644 --- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -284,11 +284,12 @@ nsresult imgRequestProxy::DispatchWithTargetIfAvailable( // rather we need to (e.g. we are in the wrong scheduler group context). // As such, we do not set mHadDispatch for telemetry purposes. if (mEventTarget) { - mEventTarget->Dispatch(std::move(aEvent), NS_DISPATCH_NORMAL); + mEventTarget->Dispatch(CreateMediumHighRunnable(std::move(aEvent)), + NS_DISPATCH_NORMAL); return NS_OK; } - return NS_DispatchToMainThread(std::move(aEvent)); + return NS_DispatchToMainThread(CreateMediumHighRunnable(std::move(aEvent))); } void imgRequestProxy::DispatchWithTarget(already_AddRefed aEvent) { @@ -298,7 +299,8 @@ void imgRequestProxy::DispatchWithTarget(already_AddRefed aEvent) { MOZ_ASSERT(mEventTarget); mHadDispatch = true; - mEventTarget->Dispatch(std::move(aEvent), NS_DISPATCH_NORMAL); + mEventTarget->Dispatch(CreateMediumHighRunnable(std::move(aEvent)), + NS_DISPATCH_NORMAL); } void imgRequestProxy::AddToOwner(Document* aLoadingDocument) {