Bug 1676996 - Don't try to process-switch a remote frame to local. r=nika

The guess in comment 3 is basically right, here's the relevant bits that
happen in that trace in order:

[content] nsFrameLoaderOwner::ChangeRemotenessCommon:
  frame becomes remote for the content process.
[parent] WindowGlobalParent::SendMakeFrameLocal (mIsDocumentLoad=true)
[content] ContentChild::SendCloneDocumentTreeInto
[parent] ContentParent::RecvCloneDocumentTreeInto
[content] WindowGlobalChild::RecvMakeFrameLocal

So basically the source frame we're cloning is mid-switch-to-local:
local already from the parent process POV, but still remote for the
child.

I think ignoring the clone in this case is fine (which will make the
print iframe just about:blank).

I've decided it to handle it in ChangeRemoteness but I could also handle
it in RecvCloneDocumentTreeInto with a check like

    if (cp->GetRemoteType() == GetRemoteType())

or such I think. Let me know if you'd prefer that.

Differential Revision: https://phabricator.services.mozilla.com/D97144
This commit is contained in:
Emilio Cobos Álvarez 2020-11-19 17:44:30 +00:00
Родитель 2bdda4c2d6
Коммит c839b29aa8
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -1330,7 +1330,7 @@ CanonicalBrowsingContext::ChangeRemoteness(const nsACString& aRemoteType,
embedderWindowGlobal->GetBrowserParent();
// Switching to local. No new process, so perform switch sync.
if (embedderBrowser &&
aRemoteType.Equals(embedderBrowser->Manager()->GetRemoteType())) {
aRemoteType == embedderBrowser->Manager()->GetRemoteType()) {
MOZ_DIAGNOSTIC_ASSERT(
aPendingSwitchId,
"We always have a PendingSwitchId, except for print-preview loads, "

Просмотреть файл

@ -3664,6 +3664,19 @@ mozilla::ipc::IPCResult ContentParent::RecvCloneDocumentTreeInto(
return IPC_OK();
}
if (NS_WARN_IF(cp->GetRemoteType() == GetRemoteType())) {
// Wanted to switch to a target browsing context that's already local again.
// See bug 1676996 for how this can happen.
//
// Dropping the switch on the floor seems fine for this case, though we
// could also try to clone the local document.
//
// If the remote type matches & it's in the same group (which was confirmed
// by CloneIsLegal), it must be the exact same process.
MOZ_DIAGNOSTIC_ASSERT(cp == this);
return IPC_OK();
}
target
->ChangeRemoteness(cp->GetRemoteType(), /* aLoadID = */ 0,
/* aReplaceBC = */ false, /* aSpecificGroupId = */ 0)