Bug 1444541 - Don't stop recorder on pagehide during frameswap. r?smaug draft
authorAndreas Pehrson <pehrsons@mozilla.com>
Mon, 19 Mar 2018 15:52:36 +0100
changeset 769412 10fc1ac1e8dd73aac829a5366fd96390ae231285
parent 764177 cb3b2b090314e6b1c4bc0bc7ebe7814ba474d974
push id103114
push userbmo:apehrson@mozilla.com
push dateMon, 19 Mar 2018 15:03:58 +0000
reviewerssmaug
bugs1444541
milestone60.0a1
Bug 1444541 - Don't stop recorder on pagehide during frameswap. r?smaug MozReview-Commit-ID: AZec0yXM1FI
dom/media/MediaRecorder.cpp
dom/media/moz.build
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -25,16 +25,17 @@
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TaskQueue.h"
 #include "nsAutoPtr.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentTypeParser.h"
 #include "nsContentUtils.h"
+#include "nsDocShell.h"
 #include "nsError.h"
 #include "nsIDocument.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsMimeTypes.h"
 #include "nsProxyRelease.h"
 #include "nsTArray.h"
@@ -1694,19 +1695,30 @@ MediaRecorder::RemoveSession(Session* aS
 void
 MediaRecorder::NotifyOwnerDocumentActivityChanged()
 {
   nsPIDOMWindowInner* window = GetOwner();
   NS_ENSURE_TRUE_VOID(window);
   nsIDocument* doc = window->GetExtantDoc();
   NS_ENSURE_TRUE_VOID(doc);
 
-  LOG(LogLevel::Debug, ("MediaRecorder %p document IsActive %d isVisible %d\n",
-                     this, doc->IsActive(), doc->IsVisible()));
-  if (!doc->IsActive() || !doc->IsVisible()) {
+  bool inFrameSwap = false;
+  if (nsDocShell* docShell = static_cast<nsDocShell*>(doc->GetDocShell())) {
+    inFrameSwap = docShell->InFrameSwap();
+  }
+
+  LOG(LogLevel::Debug, ("MediaRecorder %p NotifyOwnerDocumentActivityChanged "
+                        "IsActive=%d, "
+                        "IsVisible=%d, "
+                        "InFrameSwap=%d",
+                        this,
+                        doc->IsActive(),
+                        doc->IsVisible(),
+                        inFrameSwap));
+  if (!doc->IsActive() || !(inFrameSwap || doc->IsVisible())) {
     // Stop the session.
     ErrorResult result;
     Stop(result);
     result.SuppressException();
   }
 }
 
 void
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -307,16 +307,17 @@ EXTRA_COMPONENTS += [
 EXTRA_JS_MODULES.media += [
     'IdpSandbox.jsm',
     'PeerConnectionIdp.jsm',
     'RTCStatsReport.jsm',
 ]
 
 LOCAL_INCLUDES += [
     '/caps',
+    '/docshell/base',
     '/dom/base',
     '/layout/generic',
     '/layout/xul',
     '/netwerk/base',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     LOCAL_INCLUDES += [