Bug 1156201 - Reset the video dimensions cache when in initial room states to avoid issues with not correctly displaying video streams when a room is re-entered. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Wed, 22 Apr 2015 19:17:15 +0100
changeset 240632 5e4ea8c83c51a5dbf018f53c077aa9a020bdd9e1
parent 240631 6a62f0b8a1d8ebaddcb7f35b94c086e3a456a9d9
child 240633 da3e6557e0301899024eeaa24b0a43e837a409d7
push id28639
push usercbook@mozilla.com
push dateThu, 23 Apr 2015 13:34:21 +0000
treeherdermozilla-central@3574449bd314 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1156201
milestone40.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 1156201 - Reset the video dimensions cache when in initial room states to avoid issues with not correctly displaying video streams when a room is re-entered. r=mikedeboer
browser/components/loop/content/shared/js/mixins.js
browser/components/loop/standalone/content/js/standaloneRoomViews.js
browser/components/loop/standalone/content/js/standaloneRoomViews.jsx
browser/components/loop/test/standalone/standaloneRoomViews_test.js
--- a/browser/components/loop/content/shared/js/mixins.js
+++ b/browser/components/loop/content/shared/js/mixins.js
@@ -236,16 +236,28 @@ loop.shared.mixins = (function() {
     },
 
     componentWillUnmount: function() {
       rootObject.removeEventListener("orientationchange", this.updateVideoContainer);
       rootObject.removeEventListener("resize", this.updateVideoContainer);
     },
 
     /**
+     * Resets the dimensions cache, e.g. for when the session is ended, and
+     * before a new session, so that we always ensure we see an update when a
+     * new session is started.
+     */
+    resetDimensionsCache: function() {
+      this._videoDimensionsCache = {
+        local: {},
+        remote: {}
+      };
+    },
+
+    /**
      * Whenever the dimensions change of a video stream, this function is called
      * by `updateVideoDimensions` to store the new values and notifies the callee
      * if the dimensions changed compared to the currently stored values.
      *
      * @param  {String} which         Type of video stream. May be 'local' or 'remote'
      * @param  {Object} newDimensions Object containing 'width' and 'height' properties
      * @return {Boolean}              `true` when the dimensions have changed,
      *                                `false` if not
--- a/browser/components/loop/standalone/content/js/standaloneRoomViews.js
+++ b/browser/components/loop/standalone/content/js/standaloneRoomViews.js
@@ -378,16 +378,22 @@ loop.standaloneRoomViews = (function(moz
       if (this.state.roomState !== ROOM_STATES.JOINED &&
           nextState.roomState === ROOM_STATES.JOINED) {
         // This forces the video size to update - creating the publisher
         // first, and then connecting to the session doesn't seem to set the
         // initial size correctly.
         this.updateVideoContainer();
       }
 
+      if (nextState.roomState === ROOM_STATES.INIT ||
+          nextState.roomState === ROOM_STATES.GATHER ||
+          nextState.roomState === ROOM_STATES.READY) {
+        this.resetDimensionsCache();
+      }
+
       // When screen sharing stops.
       if (this.state.receivingScreenShare && !nextState.receivingScreenShare) {
         // Remove the custom screenshare styles on the remote camera.
         var node = this._getElement(".remote");
         node.removeAttribute("style");
 
         // Force the video sizes to update.
         this.updateVideoContainer();
--- a/browser/components/loop/standalone/content/js/standaloneRoomViews.jsx
+++ b/browser/components/loop/standalone/content/js/standaloneRoomViews.jsx
@@ -378,16 +378,22 @@ loop.standaloneRoomViews = (function(moz
       if (this.state.roomState !== ROOM_STATES.JOINED &&
           nextState.roomState === ROOM_STATES.JOINED) {
         // This forces the video size to update - creating the publisher
         // first, and then connecting to the session doesn't seem to set the
         // initial size correctly.
         this.updateVideoContainer();
       }
 
+      if (nextState.roomState === ROOM_STATES.INIT ||
+          nextState.roomState === ROOM_STATES.GATHER ||
+          nextState.roomState === ROOM_STATES.READY) {
+        this.resetDimensionsCache();
+      }
+
       // When screen sharing stops.
       if (this.state.receivingScreenShare && !nextState.receivingScreenShare) {
         // Remove the custom screenshare styles on the remote camera.
         var node = this._getElement(".remote");
         node.removeAttribute("style");
 
         // Force the video sizes to update.
         this.updateVideoContainer();
--- a/browser/components/loop/test/standalone/standaloneRoomViews_test.js
+++ b/browser/components/loop/test/standalone/standaloneRoomViews_test.js
@@ -209,16 +209,29 @@ describe("loop.standaloneRoomViews", fun
           var view = mountTestComponent();
 
           sandbox.stub(view, "updateVideoContainer");
 
           activeRoomStore.setStoreState({roomState: ROOM_STATES.JOINED});
 
           sinon.assert.calledOnce(view.updateVideoContainer);
       });
+
+      it("should reset the video dimensions cache when the gather state is entered", function() {
+        activeRoomStore.setStoreState({roomState: ROOM_STATES.SESSION_CONNECTED});
+
+        var view = mountTestComponent();
+
+        activeRoomStore.setStoreState({roomState: ROOM_STATES.GATHER});
+
+        expect(view._videoDimensionsCache).eql({
+          local: {},
+          remote: {}
+        });
+      })
     });
 
     describe("#publishStream", function() {
       var view;
 
       beforeEach(function() {
         view = mountTestComponent();
         view.setState({