Bug 1512838 - Skip over empty transaction buckets in isLayerized. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 17 Mar 2019 10:42:18 +0000
changeset 464719 729056f6dc85
parent 464718 aededeb1f164
child 464720 cb58de9731cb
push id80670
push userkgupta@mozilla.com
push dateSun, 17 Mar 2019 10:43:36 +0000
treeherderautoland@cb58de9731cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1512838
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 1512838 - Skip over empty transaction buckets in isLayerized. r=botond Sometimes we can get empty transactions after a scrollframe is layerized. In such cases the isLayerized check would incorrectly detect the scrollframe as not being layerized because it would only look at the data for the empty transaction. Differential Revision: https://phabricator.services.mozilla.com/D23495
gfx/layers/apz/test/mochitest/apz_test_utils.js
--- a/gfx/layers/apz/test/mochitest/apz_test_utils.js
+++ b/gfx/layers/apz/test/mochitest/apz_test_utils.js
@@ -52,16 +52,19 @@ function convertBuckets(buckets) {
 
 function convertTestData(testData) {
   var result = {};
   result.paints = convertBuckets(testData.paints);
   result.repaintRequests = convertBuckets(testData.repaintRequests);
   return result;
 }
 
+// Returns the last bucket that has at least one scrollframe. This
+// is useful for skipping over buckets that are from empty transactions,
+// because those don't contain any useful data.
 function getLastNonemptyBucket(buckets) {
   for (var i = buckets.length - 1; i >= 0; --i) {
     if (buckets[i].scrollFrames.length > 0) {
       return buckets[i];
     }
   }
   return null;
 }
@@ -121,18 +124,19 @@ function findRcdNode(apzcTree) {
   return null;
 }
 
 // Return whether an element whose id includes |elementId| has been layerized.
 // Assumes |elementId| will be present in the content description for the
 // element, and not in the content descriptions of other elements.
 function isLayerized(elementId) {
   var contentTestData = SpecialPowers.getDOMWindowUtils(window).getContentAPZTestData();
-  ok(contentTestData.paints.length > 0, "expected at least one paint");
-  var seqno = contentTestData.paints[contentTestData.paints.length - 1].sequenceNumber;
+  var nonEmptyBucket = getLastNonemptyBucket(contentTestData.paints);
+  ok(nonEmptyBucket != null, "expected at least one nonempty paint");
+  var seqno = nonEmptyBucket.sequenceNumber;
   contentTestData = convertTestData(contentTestData);
   var paint = contentTestData.paints[seqno];
   for (var scrollId in paint) {
     if ("contentDescription" in paint[scrollId]) {
       if (paint[scrollId].contentDescription.includes(elementId)) {
         return true;
       }
     }