Bug 1440607 - Move getAnimations call out of the rAF for the WebRTC blinking animation. r=florian draft
authorJohann Hofmann <jhofmann@mozilla.com>
Tue, 27 Feb 2018 22:46:32 +0100
changeset 762252 d891865c6a442249038ece0704e2cdbe17c6c793
parent 762250 2667f0b010c959940d7a12b4311d54a6abd74ac5
push id101109
push userjhofmann@mozilla.com
push dateThu, 01 Mar 2018 23:02:22 +0000
reviewersflorian
bugs1440607
milestone60.0a1
Bug 1440607 - Move getAnimations call out of the rAF for the WebRTC blinking animation. r=florian MozReview-Commit-ID: It4buk33ea7
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -8067,28 +8067,23 @@ var gIdentityHandler = {
       classes += " blocked-permission-icon";
 
     if (aPermission.sharingState == Ci.nsIMediaManagerService.STATE_CAPTURE_ENABLED ||
        (aPermission.id == "screen" && aPermission.sharingState &&
         !aPermission.sharingState.includes("Paused"))) {
       classes += " in-use";
 
       // Synchronize control center and identity block blinking animations.
-      window.promiseDocumentFlushed(() => {}).then(() => {
+      window.promiseDocumentFlushed(() => {
         let sharingIconBlink = document.getElementById("sharing-icon").getAnimations()[0];
-        if (sharingIconBlink) {
-          let startTime = sharingIconBlink.startTime;
-          window.requestAnimationFrame(() => {
-            // TODO(Bug 1440607): This could cause a style flush, but putting
-            // the getAnimations() call outside of rAF causes a leak.
-            let imgBlink = img.getAnimations()[0];
-            if (imgBlink) {
-              imgBlink.startTime = startTime;
-            }
-          });
+        let imgBlink = img.getAnimations()[0];
+        return [sharingIconBlink, imgBlink];
+      }).then(([sharingIconBlink, imgBlink]) => {
+        if (sharingIconBlink && imgBlink) {
+          imgBlink.startTime = sharingIconBlink.startTime;
         }
       });
     }
     img.setAttribute("class", classes);
 
     let nameLabel = document.createElement("label");
     nameLabel.setAttribute("flex", "1");
     nameLabel.setAttribute("class", "identity-popup-permission-label");