Bug 1184283 - inform e10s child browser tabs/puppet widgets proper vsync display ID
From 0b3eb8f3e83f09e0af4c472725153ee790802190 Mon Sep 17 00:00:00 2001
---
dom/ipc/ContentChild.cpp | 6 ++++--
dom/ipc/PBrowser.ipdl | 1 +
dom/ipc/TabChild.cpp | 4 ++++
dom/ipc/TabParent.cpp | 10 ++++++++--
widget/PuppetWidget.cpp | 15 +++++++++++++++
widget/PuppetWidget.h | 5 +++++
6 files changed, 37 insertions(+), 4 deletions(-)
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -197,16 +197,17 @@
#include "mozilla/dom/time/DateCacheCleaner.h"
#include "mozilla/dom/voicemail/VoicemailIPCService.h"
#include "mozilla/net/NeckoMessageUtils.h"
#include "mozilla/widget/PuppetBidiKeyboard.h"
#include "mozilla/RemoteSpellCheckEngineChild.h"
#include "GMPServiceChild.h"
#include "GMPDecoderModule.h"
#include "gfxPlatform.h"
+#include "gfxVsync.h"
#include "nscore.h" // for NS_FREE_PERMANENT_DATA
#include "VRManagerChild.h"
using namespace mozilla;
using namespace mozilla::docshell;
using namespace mozilla::dom::bluetooth;
using namespace mozilla::dom::cellbroadcast;
using namespace mozilla::dom::devicestorage;
@@ -903,24 +904,25 @@ ContentChild::ProvideWindowCommon(TabChi
newChild->SendGetRenderFrameInfo(renderFrame,
&textureFactoryIdentifier,
&layersId);
if (layersId == 0) { // if renderFrame is invalid.
PRenderFrameChild::Send__delete__(renderFrame);
renderFrame = nullptr;
}
- ShowInfo showInfo(EmptyString(), false, false, true, 0, 0);
+ ShowInfo showInfo(EmptyString(), false, false, true, 0, 0, gfx::VsyncManager::kGlobalDisplaySourceID);
nsCOMPtr<nsPIDOMWindow> opener = do_QueryInterface(aParent);
nsIDocShell* openerShell;
if (opener && (openerShell = opener->GetDocShell())) {
nsCOMPtr<nsILoadContext> context = do_QueryInterface(openerShell);
showInfo = ShowInfo(EmptyString(), false,
context->UsePrivateBrowsing(), true,
- aTabOpener->mDPI, aTabOpener->mDefaultScale);
+ aTabOpener->mDPI, aTabOpener->mDefaultScale,
+ gfx::VsyncManager::kGlobalDisplaySourceID);
}
// Unfortunately we don't get a window unless we've shown the frame. That's
// pretty bogus; see bug 763602.
newChild->DoFakeShow(textureFactoryIdentifier, layersId, renderFrame,
showInfo);
for (size_t i = 0; i < frameScripts.Length(); i++) {
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -90,16 +90,17 @@ union MaybeNativeKeyBinding
struct ShowInfo
{
nsString name;
bool fullscreenAllowed;
bool isPrivate;
bool fakeShowInfo;
float dpi;
double defaultScale;
+ nsID vsyncDisplayID;
};
prio(normal upto urgent) sync protocol PBrowser
{
manager PContent or PContentBridge;
manages PColorPicker;
manages PDocAccessible;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -101,16 +101,17 @@
#include "nsPresShell.h"
#include "nsIAppsService.h"
#include "nsNetUtil.h"
#include "nsIPermissionManager.h"
#include "nsIURILoader.h"
#include "nsIScriptError.h"
#include "mozilla/EventForwards.h"
#include "nsDeviceContext.h"
+#include "gfxVsync.h"
#define BROWSER_ELEMENT_CHILD_SCRIPT \
NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js")
#define TABC_LOG(...)
// #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__)
using namespace mozilla;
@@ -1490,16 +1491,19 @@ TabChild::ApplyShowInfo(const ShowInfo&
} else {
context->SetUsePrivateBrowsing(true);
}
}
}
}
mDPI = aInfo.dpi();
mDefaultScale = aInfo.defaultScale();
+ if (mPuppetWidget) {
+ mPuppetWidget->SetVsyncSourceID(aInfo.vsyncDisplayID());
+ }
}
#ifdef MOZ_WIDGET_GONK
void
TabChild::MaybeRequestPreinitCamera()
{
// Check if this tab is an app (not a browser frame) and will use the
// `camera` permission,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3428,29 +3428,35 @@ TabParent::StartPersistence(uint64_t aOu
? NS_OK : NS_ERROR_FAILURE;
// (The actor will be destroyed on constructor failure.)
}
ShowInfo
TabParent::GetShowInfo()
{
TryCacheDPIAndScale();
+ nsCOMPtr<nsIWidget> widget = GetWidget();
+ nsID vsyncDisplay = gfx::VsyncManager::kGlobalDisplaySourceID;
+ if (widget) {
+ vsyncDisplay = widget->GetVsyncSourceIdentifier();
+ }
+
if (mFrameElement) {
nsAutoString name;
mFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
bool allowFullscreen =
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) ||
mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozallowfullscreen);
bool isPrivate = mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::mozprivatebrowsing);
return ShowInfo(name, allowFullscreen, isPrivate, false,
- mDPI, mDefaultScale.scale);
+ mDPI, mDefaultScale.scale, vsyncDisplay);
}
return ShowInfo(EmptyString(), false, false, false,
- mDPI, mDefaultScale.scale);
+ mDPI, mDefaultScale.scale, vsyncDisplay);
}
void
TabParent::AudioChannelChangeNotification(nsPIDOMWindow* aWindow,
AudioChannel aAudioChannel,
float aVolume,
bool aMuted)
{
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -24,16 +24,19 @@
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::hal;
using namespace mozilla::gfx;
using namespace mozilla::layers;
using namespace mozilla::widget;
+extern PRLogModuleInfo *gVsyncLog;
+#define VSYNC_LOG(...) MOZ_LOG(gVsyncLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
+
static void
InvalidateRegion(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion)
{
LayoutDeviceIntRegion::RectIterator it(aRegion);
while(const LayoutDeviceIntRect* r = it.Next()) {
aWidget->Invalidate(*r);
}
}
@@ -1432,10 +1435,22 @@ PuppetWidget::ZoomToRect(const uint32_t&
{
if (!mTabChild) {
return;
}
mTabChild->SendZoomToRect(aPresShellId, aViewId, aRect, aFlags);
}
+void
+PuppetWidget::SetVsyncSourceID(const nsID& aID)
+{
+ VSYNC_LOG("PuppetWidget[%p]::SetVsyncSourceID %s", this, nsIDToCString(aID).get());
+
+ if (aID == mDesiredVsyncSourceID)
+ return;
+
+ mDesiredVsyncSourceID = aID;
+ UpdateVsyncObserver();
+}
+
} // namespace widget
} // namespace mozilla
--- a/widget/PuppetWidget.h
+++ b/widget/PuppetWidget.h
@@ -246,24 +246,29 @@ public:
uint32_t aPointerOrientation,
nsIObserver* aObserver) override;
virtual nsresult SynthesizeNativeTouchTap(ScreenIntPoint aPointerScreenPoint,
bool aLongTap,
nsIObserver* aObserver) override;
virtual nsresult ClearNativeTouchSequence(nsIObserver* aObserver) override;
virtual uint32_t GetMaxTouchPoints() const override;
+
virtual void StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) override;
+
virtual void SetCandidateWindowForPlugin(int32_t aX, int32_t aY) override;
virtual void ZoomToRect(const uint32_t& aPresShellId,
const FrameMetrics::ViewID& aViewId,
const CSSRect& aRect,
const uint32_t& aFlags) override;
+
+ void SetVsyncSourceID(const nsID& aID);
+
protected:
virtual nsresult NotifyIMEInternal(
const IMENotification& aIMENotification) override;
private:
nsresult Paint();
void SetChild(PuppetWidget* aChild);