Bug 1302681 - Part 2: Fix about:telemetry for displaying dynamic events. r=chutten
☠☠ backed out by 89d41dea4847 ☠ ☠
authorGeorg Fritzsche <georg.fritzsche@googlemail.com>
Wed, 26 Jul 2017 03:10:00 -0400
changeset 420285 8e79158a7a1c3d15ec8415c1810f9c7dfd675cf3
parent 420284 7068c8d4448c81ae1787451ac1969a3fab317458
child 420286 9c0bdff48a0ac1359bad997a080019436b1b6cd2
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1302681
milestone56.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 1302681 - Part 2: Fix about:telemetry for displaying dynamic events. r=chutten Fixes that about:telemetry only shows events if there are any present in processes.parent. For some reason switching the processes in the events section also triggers HistogramSection.render(), which breaks when there are no histograms recorded in the selected process. This patch fixes it to make things work.
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1775,45 +1775,47 @@ var Events = {
   /**
    * Render the event data - if present - from the payload in a simple table.
    * @param aPayload A payload object to render the data from.
    */
   render(aPayload) {
     let eventsSection = document.getElementById("events");
     removeAllChildNodes(eventsSection);
 
-    if (!aPayload.processes || !aPayload.processes.parent) {
+    if (!aPayload.processes || !Object.values(aPayload.processes).find(p => "events" in p)) {
       return;
     }
 
     let processesSelect = document.getElementById("processes");
     let selectedProcess = processesSelect.selectedOptions.item(0).getAttribute("value");
 
     if (!aPayload.processes ||
         !selectedProcess ||
         !(selectedProcess in aPayload.processes)) {
       return;
     }
 
-    let events = aPayload.processes[selectedProcess].events;
-    const hasData = events && Object.keys(events).length > 0;
+    const hasData = Object.values(aPayload.processes).find(p => {
+      return ("events" in p) && (Object.keys(p.events).length > 0);
+    });
     setHasData("events-section", hasData);
     if (!hasData) {
       return;
     }
 
     const headings = [
       "timestampHeader",
       "categoryHeader",
       "methodHeader",
       "objectHeader",
       "valuesHeader",
       "extraHeader",
     ].map(h => bundle.GetStringFromName(h));
 
+    let events = aPayload.processes[selectedProcess].events;
     const table = GenericTable.render(events, headings);
     eventsSection.appendChild(table);
   },
 };
 
 /**
  * Helper function for showing either the toggle element or "No data collected" message for a section
  *
@@ -2087,17 +2089,18 @@ var HistogramSection = {
     let hgramsOption = hgramsSelect.selectedOptions.item(0);
     let hgramsProcess = hgramsOption.getAttribute("value");
     // "parent" histograms/keyedHistograms aren't under "parent". Fix that up.
     if (hgramsProcess === "parent") {
       hgramsProcess = "";
     }
     if (hgramsProcess &&
         "processes" in aPayload &&
-        hgramsProcess in aPayload.processes) {
+        hgramsProcess in aPayload.processes &&
+        "histograms" in aPayload.processes[hgramsProcess]) {
       histograms = aPayload.processes[hgramsProcess].histograms;
     }
 
     let hasData = Object.keys(histograms).length > 0;
     setHasData("histograms-section", hasData || hgramsSelect.options.length);
 
     if (hasData) {
       for (let [name, hgram] of Object.entries(histograms)) {