Browse Source

performance fluff

Frank-Rainer Grahl 3 months ago
parent
commit
4be298c4cd

+ 131 - 0
mozilla-release/patches/1462605-62a1.patch

@@ -0,0 +1,131 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1526653219 -7200
+# Node ID cbc132bb5984f025f5a6233d55a937a13358c8bc
+# Parent  280f46f1457c77387d111a2e42f4db88dd000c05
+Bug 1462605 - PerformanceNavigationTiming.name must be the value of the address of the current document, r=valentin
+
+diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
+--- a/dom/performance/PerformanceMainThread.cpp
++++ b/dom/performance/PerformanceMainThread.cpp
+@@ -7,16 +7,45 @@
+ #include "PerformanceMainThread.h"
+ #include "PerformanceNavigation.h"
+ #include "mozilla/dom/DOMPrefs.h"
+ #include "nsICacheInfoChannel.h"
+ 
+ namespace mozilla {
+ namespace dom {
+ 
++namespace {
++
++void
++GetURLSpecFromChannel(nsITimedChannel* aChannel, nsAString& aSpec)
++{
++  aSpec.AssignLiteral("document");
++
++  nsCOMPtr<nsIChannel> channel = do_QueryInterface(aChannel);
++  if (!channel) {
++    return;
++  }
++
++  nsCOMPtr<nsIURI> uri;
++  nsresult rv = channel->GetURI(getter_AddRefs(uri));
++  if (NS_WARN_IF(NS_FAILED(rv)) || !uri) {
++    return;
++  }
++
++  nsAutoCString spec;
++  rv = uri->GetSpec(spec);
++  if (NS_WARN_IF(NS_FAILED(rv))) {
++    return;
++  }
++
++  aSpec = NS_ConvertUTF8toUTF16(spec);
++}
++
++} // anonymous
++
+ NS_IMPL_CYCLE_COLLECTION_CLASS(PerformanceMainThread)
+ 
+ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PerformanceMainThread,
+                                                 Performance)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mTiming,
+                                 mNavigation,
+                                 mDocEntry)
+   tmp->mMozMemory = nullptr;
+@@ -288,33 +317,39 @@ PerformanceMainThread::EnsureDocEntry()
+     UniquePtr<PerformanceTimingData> timing(
+       new PerformanceTimingData(mChannel, nullptr, 0));
+ 
+     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
+     if (httpChannel) {
+       timing->SetPropertiesFromHttpChannel(httpChannel);
+     }
+ 
+-    mDocEntry = new PerformanceNavigationTiming(std::move(timing), this);
++    nsAutoString name;
++    GetURLSpecFromChannel(mChannel, name);
++
++    mDocEntry = new PerformanceNavigationTiming(std::move(timing), this, name);
+   }
+ }
+ 
+ void
+ PerformanceMainThread::CreateDocumentEntry(nsITimedChannel* aChannel)
+ {
+   MOZ_ASSERT(aChannel);
+   MOZ_ASSERT(!mDocEntry, "mDocEntry should be null.");
+ 
+   if (!nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
+     return;
+   }
+ 
++  nsAutoString name;
++  GetURLSpecFromChannel(aChannel, name);
++
+   UniquePtr<PerformanceTimingData> timing(
+       new PerformanceTimingData(aChannel, nullptr, 0));
+-  mDocEntry = new PerformanceNavigationTiming(Move(timing), this);
++  mDocEntry = new PerformanceNavigationTiming(Move(timing), this, name);
+ }
+ 
+ void
+ PerformanceMainThread::GetEntries(nsTArray<RefPtr<PerformanceEntry>>& aRetval)
+ {
+   // We return an empty list when 'privacy.resistFingerprinting' is on.
+   if (nsContentUtils::ShouldResistFingerprinting()) {
+     aRetval.Clear();
+diff --git a/dom/performance/PerformanceNavigationTiming.h b/dom/performance/PerformanceNavigationTiming.h
+--- a/dom/performance/PerformanceNavigationTiming.h
++++ b/dom/performance/PerformanceNavigationTiming.h
+@@ -25,22 +25,23 @@ class PerformanceNavigationTiming final
+ public:
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   // Note that aPerformanceTiming must be initalized with zeroTime = 0
+   // so that timestamps are relative to startTime, as opposed to the
+   // performance.timing object for which timestamps are absolute and has a
+   // zeroTime initialized to navigationStart
+   PerformanceNavigationTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
+-                              Performance* aPerformance)
+-    : PerformanceResourceTiming(std::move(aPerformanceTiming), aPerformance,
+-                                NS_LITERAL_STRING("document")) {
+-      SetEntryType(NS_LITERAL_STRING("navigation"));
+-      SetInitiatorType(NS_LITERAL_STRING("navigation"));
+-    }
++                              Performance* aPerformance,
++                              const nsAString& aName)
++    : PerformanceResourceTiming(Move(aPerformanceTiming), aPerformance, aName)
++  {
++    SetEntryType(NS_LITERAL_STRING("navigation"));
++    SetInitiatorType(NS_LITERAL_STRING("navigation"));
++  }
+ 
+   DOMHighResTimeStamp Duration() const override
+   {
+     return nsRFPService::ReduceTimePrecisionAsMSecs(LoadEventEnd() - StartTime());
+   }
+ 
+   DOMHighResTimeStamp StartTime() const override
+   {

+ 31 - 0
mozilla-release/patches/1462880-62a1.patch

@@ -0,0 +1,31 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1526712560 -7200
+# Node ID 761d1da1d483d5573f91acd0d28082e90fbed28a
+# Parent  da1299ac3b69f4a3f56943fa6c47c953bcb08857
+Bug 1462880 - Set Performance Resource Timing buffer size to 250, r=bz
+
+Spec issue: https://github.com/w3c/resource-timing/pull/155
+
+diff --git a/dom/performance/Performance.h b/dom/performance/Performance.h
+--- a/dom/performance/Performance.h
++++ b/dom/performance/Performance.h
+@@ -143,17 +143,17 @@ protected:
+   void RunNotificationObserversTask();
+   void QueueEntry(PerformanceEntry* aEntry);
+ 
+   DOMHighResTimeStamp RoundTime(double aTime) const;
+ 
+   nsTObserverArray<PerformanceObserver*> mObservers;
+ 
+ protected:
+-  static const uint64_t kDefaultResourceTimingBufferSize = 150;
++  static const uint64_t kDefaultResourceTimingBufferSize = 250;
+ 
+   // When kDefaultResourceTimingBufferSize is increased or removed, these should
+   // be changed to use SegmentedVector
+   AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mUserEntries;
+   AutoTArray<RefPtr<PerformanceEntry>, kDefaultResourceTimingBufferSize> mResourceEntries;
+ 
+   uint64_t mResourceTimingBufferSize;
+   bool mPendingNotificationObserversTask;

+ 62 - 0
mozilla-release/patches/1462883-1no2-63a1.patch

@@ -0,0 +1,62 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1533294510 -7200
+# Node ID ea6577b8c72f4800808199a7ce00aea4513040a1
+# Parent  e74d58cc2937e847aa76ead415333a0dd8a79be4
+Bug 1462883 - Performance object must be reset when the inner window changes document, r=bz
+
+diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
+--- a/dom/base/nsGlobalWindow.cpp
++++ b/dom/base/nsGlobalWindow.cpp
+@@ -3249,17 +3249,22 @@ nsGlobalWindow::SetNewDocument(nsIDocume
+ 
+       if (newInnerWindow->mDoc != aDocument) {
+         newInnerWindow->mDoc = aDocument;
+ 
+         // The storage objects contain the URL of the window. We have to
+         // recreate them when the innerWindow is reused.
+         newInnerWindow->mLocalStorage = nullptr;
+         newInnerWindow->mSessionStorage = nullptr;
+-
++        newInnerWindow->mPerformance = nullptr;
++
++        // This must be called after nullifying the internal objects because
++        // here we could recreate them, calling the getter methods, and store
++        // them into the JS slots. If we nullify them after, the slot values and
++        // the objects will be out of sync.
+         newInnerWindow->ClearDocumentDependentSlots(cx);
+ 
+         // When replacing an initial about:blank document we call
+         // ExecutionReady again to update the client creation URL.
+         rv = newInnerWindow->ExecutionReady();
+         NS_ENSURE_SUCCESS(rv, rv);
+       }
+     } else {
+@@ -3424,20 +3429,26 @@ nsGlobalWindow::InnerSetNewDocument(JSCo
+   if (MOZ_LOG_TEST(gDOMLeakPRLog, LogLevel::Debug)) {
+     nsIURI *uri = aDocument->GetDocumentURI();
+     MOZ_LOG(gDOMLeakPRLog, LogLevel::Debug,
+             ("DOMWINDOW %p SetNewDocument %s",
+              this, uri ? uri->GetSpecOrDefault().get() : ""));
+   }
+ 
+   mDoc = aDocument;
+-  ClearDocumentDependentSlots(aCx);
+   mFocusedNode = nullptr;
+   mLocalStorage = nullptr;
+   mSessionStorage = nullptr;
++  mPerformance = nullptr;
++
++  // This must be called after nullifying the internal objects because here we
++  // could recreate them, calling the getter methods, and store them into the JS
++  // slots. If we nullify them after, the slot values and the objects will be
++  // out of sync.
++  ClearDocumentDependentSlots(aCx);
+ 
+ #ifdef DEBUG
+   mLastOpenedURI = aDocument->GetDocumentURI();
+ #endif
+ 
+   Telemetry::Accumulate(Telemetry::INNERWINDOWS_WITH_MUTATION_LISTENERS,
+                         mMutationBits ? 1 : 0);
+ 

+ 110 - 0
mozilla-release/patches/1462883-3-63a1.patch

@@ -0,0 +1,110 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1533294512 -7200
+# Node ID 93bfaea2aa07b44cc18f0b022fd054be1ccadade
+# Parent  7beb6ec7407f4eb3f937e698c85bb690fcdea1b4
+Bug 1462883 - Update PerformanceTimingData::mReportCrossOriginRedirect in SetPropertiesFromHttpChannel, r=bz
+
+diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
+--- a/dom/performance/PerformanceMainThread.cpp
++++ b/dom/performance/PerformanceMainThread.cpp
+@@ -309,22 +309,23 @@ PerformanceMainThread::CreationTime() co
+ {
+   return GetDOMTiming()->GetNavigationStart();
+ }
+ 
+ void
+ PerformanceMainThread::EnsureDocEntry()
+ {
+   if (!mDocEntry && nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
++
+     UniquePtr<PerformanceTimingData> timing(
+       new PerformanceTimingData(mChannel, nullptr, 0));
+ 
+     nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
+     if (httpChannel) {
+-      timing->SetPropertiesFromHttpChannel(httpChannel);
++      timing->SetPropertiesFromHttpChannel(httpChannel, mChannel);
+     }
+ 
+     nsAutoString name;
+     GetURLSpecFromChannel(mChannel, name);
+ 
+     mDocEntry = new PerformanceNavigationTiming(std::move(timing), this, name);
+   }
+ }
+diff --git a/dom/performance/PerformanceTiming.cpp b/dom/performance/PerformanceTiming.cpp
+--- a/dom/performance/PerformanceTiming.cpp
++++ b/dom/performance/PerformanceTiming.cpp
+@@ -199,40 +199,41 @@ PerformanceTimingData::PerformanceTiming
+   }
+ 
+   // The aHttpChannel argument is null if this PerformanceTiming object is
+   // being used for navigation timing (which is only relevant for documents).
+   // It has a non-null value if this PerformanceTiming object is being used
+   // for resource timing, which can include document loads, both toplevel and
+   // in subframes, and resources linked from a document.
+   if (aHttpChannel) {
+-    mTimingAllowed = CheckAllowedOrigin(aHttpChannel, aChannel);
+-    bool redirectsPassCheck = false;
+-    aChannel->GetAllRedirectsPassTimingAllowCheck(&redirectsPassCheck);
+-    mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck;
+-
+-    SetPropertiesFromHttpChannel(aHttpChannel);
++    SetPropertiesFromHttpChannel(aHttpChannel, aChannel);
+   }
+ }
+ 
+ void
+-PerformanceTimingData::SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel)
++PerformanceTimingData::SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
++                                                    nsITimedChannel* aChannel)
+ {
+   MOZ_ASSERT(aHttpChannel);
+ 
+   nsAutoCString protocol;
+   Unused << aHttpChannel->GetProtocolVersion(protocol);
+   mNextHopProtocol = NS_ConvertUTF8toUTF16(protocol);
+ 
+   Unused << aHttpChannel->GetEncodedBodySize(&mEncodedBodySize);
+   Unused << aHttpChannel->GetTransferSize(&mTransferSize);
+   Unused << aHttpChannel->GetDecodedBodySize(&mDecodedBodySize);
+   if (mDecodedBodySize == 0) {
+     mDecodedBodySize = mEncodedBodySize;
+   }
++
++  mTimingAllowed = CheckAllowedOrigin(aHttpChannel, aChannel);
++  bool redirectsPassCheck = false;
++  aChannel->GetAllRedirectsPassTimingAllowCheck(&redirectsPassCheck);
++  mReportCrossOriginRedirect = mTimingAllowed && redirectsPassCheck;
+ }
+ 
+ PerformanceTiming::~PerformanceTiming()
+ {
+ }
+ 
+ DOMHighResTimeStamp
+ PerformanceTimingData::FetchStartHighRes(Performance* aPerformance)
+diff --git a/dom/performance/PerformanceTiming.h b/dom/performance/PerformanceTiming.h
+--- a/dom/performance/PerformanceTiming.h
++++ b/dom/performance/PerformanceTiming.h
+@@ -36,17 +36,18 @@ public:
+          nsAString& aInitiatorType,
+          nsAString& aEntryName);
+ 
+   PerformanceTimingData(nsITimedChannel* aChannel,
+                         nsIHttpChannel* aHttpChannel,
+                         DOMHighResTimeStamp aZeroTime);
+ 
+   void
+-  SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel);
++  SetPropertiesFromHttpChannel(nsIHttpChannel* aHttpChannel,
++                               nsITimedChannel* aChannel);
+ 
+   bool IsInitialized() const
+   {
+     return mInitialized;
+   }
+ 
+   const nsString& NextHopProtocol() const
+   {

+ 33 - 0
mozilla-release/patches/1463065-62a1.patch

@@ -0,0 +1,33 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1526906955 -7200
+# Node ID f61158077bd0c9358634f1476e91b6376baafa28
+# Parent  7d85bf8f8c5839eb2ebf623ca7d202091770c6d6
+Bug 1463065 - "server" is not a valid PerformanceEntry type, r=valentin
+
+diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp
+--- a/dom/performance/PerformanceObserver.cpp
++++ b/dom/performance/PerformanceObserver.cpp
+@@ -131,21 +131,20 @@ PerformanceObserver::QueueEntry(Performa
+   aEntry->GetEntryType(entryType);
+   if (!mEntryTypes.Contains<nsString>(entryType)) {
+     return;
+   }
+ 
+   mQueuedEntries.AppendElement(aEntry);
+ }
+ 
+-static const char16_t *const sValidTypeNames[4] = {
++static const char16_t *const sValidTypeNames[3] = {
+   u"mark",
+   u"measure",
+   u"resource",
+-  u"server"
+ };
+ 
+ void
+ PerformanceObserver::Observe(const PerformanceObserverInit& aOptions)
+ {
+   if (aOptions.mEntryTypes.IsEmpty()) {
+     return;
+   }

+ 29 - 7
mozilla-release/patches/1465585-3a-std-62a1.patch

@@ -2,7 +2,7 @@
 # User Emilio Cobos Alvarez <emilio@crisal.io>
 # Date 1527707735 -7200
 # Node ID b54db66223586b4e04f5cb926fccdacf8a176b91
-# Parent  9bd4ce43361fbda79e78e6218adda6e89eb77a07
+# Parent  93800e678144eca61ba38c5d7d62cdada23e67c9
 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
 
 This was done automatically replacing:
@@ -20,17 +20,17 @@ MozReview-Commit-ID: Jxze3adipUh
 diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/PerformanceMainThread.cpp
 --- a/dom/performance/PerformanceMainThread.cpp
 +++ b/dom/performance/PerformanceMainThread.cpp
-@@ -304,17 +304,17 @@ PerformanceMainThread::CreateDocumentEnt
-   MOZ_ASSERT(!mDocEntry, "mDocEntry should be null.");
- 
-   if (!nsContentUtils::IsPerformanceNavigationTimingEnabled()) {
+@@ -339,17 +339,17 @@ PerformanceMainThread::CreateDocumentEnt
      return;
    }
  
+   nsAutoString name;
+   GetURLSpecFromChannel(aChannel, name);
+ 
    UniquePtr<PerformanceTimingData> timing(
        new PerformanceTimingData(aChannel, nullptr, 0));
--  mDocEntry = new PerformanceNavigationTiming(Move(timing), this);
-+  mDocEntry = new PerformanceNavigationTiming(std::move(timing), this);
+-  mDocEntry = new PerformanceNavigationTiming(Move(timing), this, name);
++  mDocEntry = new PerformanceNavigationTiming(std::move(timing), this, name);
  }
  
  void
@@ -39,3 +39,25 @@ diff --git a/dom/performance/PerformanceMainThread.cpp b/dom/performance/Perform
    // We return an empty list when 'privacy.resistFingerprinting' is on.
    if (nsContentUtils::ShouldResistFingerprinting()) {
      aRetval.Clear();
+diff --git a/dom/performance/PerformanceNavigationTiming.h b/dom/performance/PerformanceNavigationTiming.h
+--- a/dom/performance/PerformanceNavigationTiming.h
++++ b/dom/performance/PerformanceNavigationTiming.h
+@@ -27,17 +27,17 @@ public:
+ 
+   // Note that aPerformanceTiming must be initalized with zeroTime = 0
+   // so that timestamps are relative to startTime, as opposed to the
+   // performance.timing object for which timestamps are absolute and has a
+   // zeroTime initialized to navigationStart
+   PerformanceNavigationTiming(UniquePtr<PerformanceTimingData>&& aPerformanceTiming,
+                               Performance* aPerformance,
+                               const nsAString& aName)
+-    : PerformanceResourceTiming(Move(aPerformanceTiming), aPerformance, aName)
++    : PerformanceResourceTiming(std::move(aPerformanceTiming), aPerformance, aName)
+   {
+     SetEntryType(NS_LITERAL_STRING("navigation"));
+     SetInitiatorType(NS_LITERAL_STRING("navigation"));
+   }
+ 
+   DOMHighResTimeStamp Duration() const override
+   {
+     return nsRFPService::ReduceTimePrecisionAsMSecs(LoadEventEnd() - StartTime());

+ 5 - 0
mozilla-release/patches/series

@@ -7114,7 +7114,12 @@ TOP-1906540-mozdevice-removal-mozilla-25320.patch
 1423495-4no5-61a1.patch
 1423495-6-61a1.patch
 1457401-61a1.patch
+1462605-62a1.patch
+1462880-62a1.patch
+1463065-62a1.patch
 1465585-3a-std-62a1.patch
+1462883-1no2-63a1.patch
+1462883-3-63a1.patch
 1566482-70a1.patch
 1559403-1-69a1.patch
 1559403-2-69a1.patch