From e30a2f5c84158422c52972f03cecec8cfc0b4300 Mon Sep 17 00:00:00 2001 From: Bogdan Tara Date: Tue, 1 Sep 2020 15:15:29 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1580117) for mochitest and webrender failures CLOSED TREE Backed out changeset aba57d4f19cb (bug 1580117) Backed out changeset 70b864f4b6a5 (bug 1580117) --- .../lib/ActivityStreamMessageChannel.jsm | 13 +--- .../lib/ActivityStreamMessageChannel.test.js | 62 ++++++--------- browser/modules/NewTabPagePreloading.jsm | 9 +-- widget/cocoa/nsCocoaWindow.h | 3 - widget/cocoa/nsCocoaWindow.mm | 75 ------------------- 5 files changed, 30 insertions(+), 132 deletions(-) diff --git a/browser/components/newtab/lib/ActivityStreamMessageChannel.jsm b/browser/components/newtab/lib/ActivityStreamMessageChannel.jsm index eb9a3e6e2f9f..b3e2dd660373 100644 --- a/browser/components/newtab/lib/ActivityStreamMessageChannel.jsm +++ b/browser/components/newtab/lib/ActivityStreamMessageChannel.jsm @@ -288,16 +288,11 @@ this.ActivityStreamMessageChannel = class ActivityStreamMessageChannel { */ onNewTabLoad(msg) { let { browser } = msg.target; - if ( - this.isPreloadedBrowser(browser) && - browser.ownerGlobal.windowState !== browser.ownerGlobal.STATE_MINIMIZED && - !browser.ownerGlobal.isFullyOccluded - ) { + if (this.isPreloadedBrowser(browser)) { // As a perceived performance optimization, if this loaded Activity Stream - // happens to be a preloaded browser in a window that is not minimized or - // occluded, have it render its layers to the compositor now to increase - // the odds that by the time we switch to the tab, the layers are already - // ready to present to the user. + // happens to be a preloaded browser, have it render its layers to the + // compositor now to increase the odds that by the time we switch to + // the tab, the layers are already ready to present to the user. browser.renderLayers = true; } diff --git a/browser/components/newtab/test/unit/lib/ActivityStreamMessageChannel.test.js b/browser/components/newtab/test/unit/lib/ActivityStreamMessageChannel.test.js index 93d9b44a4b95..cff3ff546e68 100644 --- a/browser/components/newtab/test/unit/lib/ActivityStreamMessageChannel.test.js +++ b/browser/components/newtab/test/unit/lib/ActivityStreamMessageChannel.test.js @@ -127,20 +127,14 @@ describe("ActivityStreamMessageChannel", () => { loaded: false, portID: "inited", simulated: true, - browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, - }, + browser: { getAttribute: () => "preloaded" }, }); RPmessagePorts.push({ url: "about:sheep", loaded: true, portID: "loaded", simulated: true, - browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, - }, + browser: { getAttribute: () => "preloaded" }, }); mm.simulateMessagesForExistingTabs(); @@ -158,10 +152,7 @@ describe("ActivityStreamMessageChannel", () => { RPmessagePorts.push({ loaded: true, portID: "foo", - browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, - }, + browser: { getAttribute: () => "preloaded" }, }); mm.simulateMessagesForExistingTabs(); @@ -176,17 +167,7 @@ describe("ActivityStreamMessageChannel", () => { RPmessagePorts.push({ loaded: true, portID: "foo", - browser: { - getAttribute: () => "preloaded", - ownerGlobal: { - STATE_MAXIMIZED: 1, - STATE_MINIMIZED: 2, - STATE_NORMAL: 3, - STATE_FULLSCREEN: 4, - windowState: 3, - isFullyOccluded: false, - }, - }, + browser: { getAttribute: () => "preloaded" }, }); mm.simulateMessagesForExistingTabs(); assert.equal(RPmessagePorts[0].browser.renderLayers, true); @@ -241,8 +222,9 @@ describe("ActivityStreamMessageChannel", () => { it("should get a preloaded browser if it exists", () => { const port = { browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, + getAttribute() { + return "preloaded"; + }, }, }; mm.createChannel(); @@ -252,8 +234,9 @@ describe("ActivityStreamMessageChannel", () => { it("should get all the preloaded browsers across windows if they exist", () => { const port = { browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, + getAttribute() { + return "preloaded"; + }, }, }; mm.createChannel(); @@ -264,8 +247,9 @@ describe("ActivityStreamMessageChannel", () => { it("should return null if there is no preloaded browser", () => { const port = { browser: { - getAttribute: () => "consumed", - ownerGlobal: {}, + getAttribute() { + return "consumed"; + }, }, }; mm.createChannel(); @@ -290,10 +274,7 @@ describe("ActivityStreamMessageChannel", () => { it("should dispatch a NEW_TAB_LOAD action", () => { const t = { portID: "foo", - browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, - }, + browser: { getAttribute: () => "preloaded" }, }; sinon.stub(mm, "onActionFromContent"); mm.onNewTabLoad({ target: t }); @@ -385,8 +366,9 @@ describe("ActivityStreamMessageChannel", () => { it("should send the message to the preloaded browser if there's data and a preloaded browser exists", () => { const port = { browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, + getAttribute() { + return "preloaded"; + }, }, sendAsyncMessage: sinon.spy(), }; @@ -403,8 +385,9 @@ describe("ActivityStreamMessageChannel", () => { it("should send the message to all the preloaded browsers if there's data and they exist", () => { const port = { browser: { - getAttribute: () => "preloaded", - ownerGlobal: {}, + getAttribute() { + return "preloaded"; + }, }, sendAsyncMessage: sinon.spy(), }; @@ -417,8 +400,9 @@ describe("ActivityStreamMessageChannel", () => { it("should not send the message to the preloaded browser if there's no data and a preloaded browser does not exists", () => { const port = { browser: { - getAttribute: () => "consumed", - ownerGlobal: {}, + getAttribute() { + return "consumed"; + }, }, sendAsyncMessage: sinon.spy(), }; diff --git a/browser/modules/NewTabPagePreloading.jsm b/browser/modules/NewTabPagePreloading.jsm index badc428cd020..d887e0c5cdc2 100644 --- a/browser/modules/NewTabPagePreloading.jsm +++ b/browser/modules/NewTabPagePreloading.jsm @@ -101,15 +101,12 @@ let NewTabPagePreloading = { }, maybeCreatePreloadedBrowser(window) { - // If we're not enabled, have already got one, are in a popup window, or the - // window is minimized / occluded, don't bother creating a preload browser - - // there's no point. + // If we're not enabled, have already got one, or are in a popup window, + // don't bother creating a preload browser - there's no point. if ( !this.enabled || window.gBrowser.preloadedBrowser || - !window.toolbar.visible || - window.windowState == window.STATE_MINIMIZED || - window.isFullyOccluded + !window.toolbar.visible ) { return; } diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index e83246d58f43..e1cd65e474a4 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -340,9 +340,6 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa { bool InFullScreenMode() const { return mInFullScreenMode; } - void PauseCompositor(); - void ResumeCompositor(); - protected: virtual ~nsCocoaWindow(); diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index fae5efd5a3d6..eb33576b0109 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -34,8 +34,6 @@ #include "nsIScreenManager.h" #include "nsIWidgetListener.h" #include "VibrancyManager.h" -#include "nsPresContext.h" -#include "nsDocShell.h" #include "gfxPlatform.h" #include "qcms.h" @@ -46,7 +44,6 @@ #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_widget.h" #include "mozilla/PresShell.h" -#include "mozilla/layers/CompositorBridgeChild.h" #include namespace mozilla { @@ -2093,12 +2090,6 @@ void nsCocoaWindow::DispatchOcclusionEvent() { if (mWidgetListener) { mWidgetListener->OcclusionStateChanged(mIsFullyOccluded); } - - if (mIsFullyOccluded) { - PauseCompositor(); - } else { - ResumeCompositor(); - } } void nsCocoaWindow::ReportSizeEvent() { @@ -2114,72 +2105,6 @@ void nsCocoaWindow::ReportSizeEvent() { NS_OBJC_END_TRY_ABORT_BLOCK; } -void nsCocoaWindow::PauseCompositor() { - nsIWidget* mainChildView = static_cast([[mWindow mainChildView] widget]); - if (!mainChildView) { - return; - } - CompositorBridgeChild* remoteRenderer = mainChildView->GetRemoteRenderer(); - if (!remoteRenderer) { - return; - } - remoteRenderer->SendPause(); - - // Now that the compositor has paused, we also try to mark the browser window - // docshell inactive to stop any animations. This does not affect docshells - // for browsers in other processes, but browser UI code should be managing - // their active state appropriately. - if (!mWidgetListener) { - return; - } - PresShell* presShell = mWidgetListener->GetPresShell(); - if (!presShell) { - return; - } - nsPresContext* presContext = presShell->GetPresContext(); - if (!presContext) { - return; - } - nsDocShell* docShell = presContext->GetDocShell(); - if (!docShell) { - return; - } - docShell->SetIsActive(false); -} - -void nsCocoaWindow::ResumeCompositor() { - nsIWidget* mainChildView = static_cast([[mWindow mainChildView] widget]); - if (!mainChildView) { - return; - } - CompositorBridgeChild* remoteRenderer = mainChildView->GetRemoteRenderer(); - if (!remoteRenderer) { - return; - } - remoteRenderer->SendResume(); - - // Now that the compositor has resumed, we also try to mark the browser window - // docshell active to restart any animations. This does not affect docshells - // for browsers in other processes, but browser UI code should be managing - // their active state appropriately. - if (!mWidgetListener) { - return; - } - PresShell* presShell = mWidgetListener->GetPresShell(); - if (!presShell) { - return; - } - nsPresContext* presContext = presShell->GetPresContext(); - if (!presContext) { - return; - } - nsDocShell* docShell = presContext->GetDocShell(); - if (!docShell) { - return; - } - docShell->SetIsActive(true); -} - void nsCocoaWindow::SetMenuBar(nsMenuBarX* aMenuBar) { if (mMenuBar) mMenuBar->SetParent(nullptr); if (!mWindow) {