Bug 1519567, use medium high priority queue for imglib notifications, r=tnikkel
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 01 Mar 2019 15:11:56 +0200
changeset 462087 339a3c5969e1ccea01a68a0c61373cffd7436022
parent 462086 9965eaf1e975e5f4ea2e5f71f632bd157ee4bb65
child 462088 6b78699bdf7ba05ed68892140dec7ba175ba95d9
push id35635
push userrmaries@mozilla.com
push dateSat, 02 Mar 2019 09:41:56 +0000
treeherdermozilla-central@82134a2f7b89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1519567
milestone67.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
Bug 1519567, use medium high priority queue for imglib notifications, r=tnikkel
image/IDecodingTask.cpp
image/Image.cpp
image/VectorImage.cpp
image/imgRequestProxy.cpp
--- a/image/IDecodingTask.cpp
+++ b/image/IDecodingTask.cpp
@@ -77,23 +77,23 @@ void IDecodingTask::NotifyProgress(NotNu
   if (IsOnEventTarget() && !(decoderFlags & DecoderFlags::ASYNC_NOTIFY)) {
     aImage->NotifyProgress(progress, invalidRect, frameCount, decoderFlags,
                            surfaceFlags);
     return;
   }
 
   // We're forced to notify asynchronously.
   NotNull<RefPtr<RasterImage>> 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);
 }
 
 void IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
                                          NotNull<Decoder*> aDecoder) {
   MOZ_ASSERT(aDecoder->HasError() || !aDecoder->InFrame(),
              "Decode complete in the middle of a frame?");
   EnsureHasEventTarget(aImage);
@@ -113,25 +113,25 @@ void IDecodingTask::NotifyDecodeComplete
     aImage->NotifyDecodeComplete(finalStatus, metadata, telemetry, progress,
                                  invalidRect, frameCount, decoderFlags,
                                  surfaceFlags);
     return;
   }
 
   // We're forced to notify asynchronously.
   NotNull<RefPtr<RasterImage>> 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);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
 // IDecodingTask implementation.
 ///////////////////////////////////////////////////////////////////////////////
 
 void IDecodingTask::Resume() { DecodePool::Singleton()->AsyncRun(this); }
 
--- a/image/Image.cpp
+++ b/image/Image.cpp
@@ -395,17 +395,18 @@ void ImageResource::SendOnUnlockedDraw(u
     nsCOMPtr<nsIEventTarget> eventTarget = mProgressTracker->GetEventTarget();
     nsCOMPtr<nsIRunnable> ev = NS_NewRunnableFunction(
         "image::ImageResource::SendOnUnlockedDraw", [=]() -> void {
           RefPtr<ProgressTracker> tracker = image->GetProgressTracker();
           if (tracker) {
             tracker->OnUnlockedDraw();
           }
         });
-    eventTarget->Dispatch(ev.forget(), NS_DISPATCH_NORMAL);
+    eventTarget->Dispatch(CreateMediumHighRunnable(ev.forget()),
+                          NS_DISPATCH_NORMAL);
   }
 }
 
 #ifdef DEBUG
 void ImageResource::NotifyDrawingObservers() {
   if (!mURI || !NS_IsMainThread()) {
     return;
   }
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1175,24 +1175,24 @@ void VectorImage::SendFrameComplete(bool
 
   // Send out an invalidation so that surfaces that are still in use get
   // re-locked. See the discussion of the UnlockSurfaces call above.
   if (!(aFlags & FLAG_ASYNC_NOTIFY)) {
     mProgressTracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE,
                                          GetMaxSizedIntRect());
   } else {
     NotNull<RefPtr<VectorImage>> image = WrapNotNull(this);
-    NS_DispatchToMainThread(NS_NewRunnableFunction(
+    NS_DispatchToMainThread(CreateMediumHighRunnable(NS_NewRunnableFunction(
         "ProgressTracker::SyncNotifyProgress", [=]() -> void {
           RefPtr<ProgressTracker> tracker = image->GetProgressTracker();
           if (tracker) {
             tracker->SyncNotifyProgress(FLAG_FRAME_COMPLETE,
                                         GetMaxSizedIntRect());
           }
-        }));
+        })));
   }
 }
 
 void VectorImage::Show(gfxDrawable* aDrawable,
                        const SVGDrawingParameters& aParams) {
   // The surface size may differ from the size at which we wish to draw. As
   // such, we may need to adjust the context/region to take this into account.
   gfxContextMatrixAutoSaveRestore saveMatrix(aParams.context);
@@ -1508,17 +1508,18 @@ void VectorImage::InvalidateObserversOnN
   } else {
     eventTarget = do_GetMainThread();
   }
 
   RefPtr<VectorImage> self(this);
   nsCOMPtr<nsIRunnable> 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) {
   Document* doc = mSVGDocumentWrapper->GetDocument();
   if (doc) {
     doc->PropagateUseCounters(aParentDocument);
   }
 }
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -279,31 +279,33 @@ nsresult imgRequestProxy::DispatchWithTa
     already_AddRefed<nsIRunnable> aEvent) {
   LOG_FUNC(gImgLog, "imgRequestProxy::DispatchWithTargetIfAvailable");
 
   // This method should only be used when it is *expected* that we are
   // dispatching an event (e.g. we want to handle an event asynchronously)
   // 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<nsIRunnable> aEvent) {
   LOG_FUNC(gImgLog, "imgRequestProxy::DispatchWithTarget");
 
   MOZ_ASSERT(mListener || mTabGroup);
   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) {
   // An imgRequestProxy can be initialized with neither a listener nor a
   // document. The caller could follow up later by cloning the canonical
   // imgRequestProxy with the actual listener. This is possible because
   // imgLoader::LoadImage does not require a valid listener to be provided.
   //