Bug 1444541 - Don't stop recorder on pagehide during frameswap. r?smaug
MozReview-Commit-ID: AZec0yXM1FI
--- 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 += [