Skip to content

Commit

Permalink
#446: reduce throttle interval
Browse files Browse the repository at this point in the history
  • Loading branch information
classilla committed Dec 29, 2017
1 parent 0580d4c commit a6dbf7e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 43 deletions.
5 changes: 5 additions & 0 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6024,6 +6024,11 @@ nsDocShell::SetIsActive(bool aIsActive)
nsresult
nsDocShell::SetIsActiveInternal(bool aIsActive, bool aIsHidden)
{
// We disallow setting active on chrome docshells.
if (mItemType == nsIDocShellTreeItem::typeChrome) {
return NS_ERROR_INVALID_ARG;
}

// Keep track ourselves.
mIsActive = aIsActive;

Expand Down
34 changes: 13 additions & 21 deletions layout/base/nsRefreshDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,16 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer

void OnTimerStart()
{
#if(0)
if (!XRE_IsParentProcess()) {
mLastChildTick = TimeStamp::Now();
}
#endif
}

private:
virtual ~RefreshDriverVsyncObserver() {}

void RecordTelemetryProbes(TimeStamp aVsyncTimestamp)
{
#if(0)
MOZ_ASSERT(NS_IsMainThread());
#ifndef ANDROID /* bug 1142079 */
if (XRE_IsParentProcess()) {
Expand Down Expand Up @@ -466,21 +463,20 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer
mVsyncRate = mVsyncRefreshDriverTimer->mVsyncChild->GetVsyncRate();
}
#endif
#endif
}

void TickRefreshDriver(TimeStamp aVsyncTimestamp)
{
MOZ_ASSERT(NS_IsMainThread());

//RecordTelemetryProbes(aVsyncTimestamp);
//if (XRE_IsParentProcess()) {
RecordTelemetryProbes(aVsyncTimestamp);
if (XRE_IsParentProcess()) {
MonitorAutoLock lock(mRefreshTickLock);
aVsyncTimestamp = mRecentVsync;
mProcessedVsync = true;
//} else {
// mLastChildTick = TimeStamp::Now();
//}
} else {
mLastChildTick = TimeStamp::Now();
}
MOZ_ASSERT(aVsyncTimestamp <= TimeStamp::Now());

// We might have a problem that we call ~VsyncRefreshDriverTimer() before
Expand All @@ -504,10 +500,9 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer

virtual ~VsyncRefreshDriverTimer()
{
//if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess()) {
mVsyncDispatcher->SetParentRefreshTimer(nullptr);
mVsyncDispatcher = nullptr;
#if(0)
} else {
// Since the PVsyncChild actors live through the life of the process, just
// send the unobserveVsync message to disable vsync event. We don't need
Expand All @@ -517,7 +512,6 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer
mVsyncChild->SetVsyncObserver(nullptr);
mVsyncChild = nullptr;
}
#endif

// Detach current vsync timer from this VsyncObserver. The observer will no
// longer tick this timer.
Expand Down Expand Up @@ -548,11 +542,11 @@ class VsyncRefreshDriverTimer : public RefreshDriverTimer
// Protect updates to `sActiveVsyncTimers`.
MOZ_ASSERT(NS_IsMainThread());

//if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess()) {
mVsyncDispatcher->SetParentRefreshTimer(nullptr);
//} else {
// Unused << mVsyncChild->SendUnobserve();
//}
} else {
Unused << mVsyncChild->SendUnobserve();
}

MOZ_ASSERT(sActiveVsyncTimers > 0);
--sActiveVsyncTimers;
Expand Down Expand Up @@ -685,8 +679,6 @@ class InactiveRefreshDriverTimer final :

virtual void ScheduleNextTick(TimeStamp aNowTime)
{
return; // speculative from bug 1352205 and TenFourFox issue 446

if (mDisableAfterMilliseconds > 0.0 &&
mNextTickDuration > mDisableAfterMilliseconds)
{
Expand Down Expand Up @@ -836,14 +828,14 @@ CreateVsyncRefreshTimer()
return;
}

//if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess()) {
// Make sure all vsync systems are ready.
gfxPlatform::GetPlatform();
// In parent process, we don't need to use ipc. We can create the
// VsyncRefreshDriverTimer directly.
sRegularRateTimer = new VsyncRefreshDriverTimer();
return;
//}
}

#ifdef MOZ_NUWA_PROCESS
// NUWA process will just use software timer. Use NuwaAddFinalConstructor()
Expand Down Expand Up @@ -1882,7 +1874,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
}
}

#if(0)
#ifndef ANDROID /* bug 1142079 */
mozilla::Telemetry::AccumulateTimeDelta(mozilla::Telemetry::REFRESH_DRIVER_TICK, mTickStart);
#endif

Expand Down
6 changes: 0 additions & 6 deletions toolkit/xre/nsEmbedFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,6 @@ XRE_SetProcessType(const char* aProcessTypeString)
i < (int) ArrayLength(kGeckoProcessTypeString);
++i) {
if (!strcmp(kGeckoProcessTypeString[i], aProcessTypeString)) {
// For purposes of TenFourFox issue 441, assert that we never, ever
// launch a child process (it would immediately crash anyway due to
// defective IPC, but let's be paranoid and make it crash predictably).
if (MOZ_UNLIKELY(static_cast<GeckoProcessType>(i) != GeckoProcessType_Default))
MOZ_CRASH("TenFourFox does not support E10S child processes.");

sChildProcessType = static_cast<GeckoProcessType>(i);
return;
}
Expand Down
35 changes: 19 additions & 16 deletions xpfe/appshell/nsAppShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,34 @@ nsAppShellService::CreateHiddenWindowHelper(bool aIsPrivate)
rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL);
NS_ENSURE_SUCCESS(rv, rv);

if (aIsPrivate) {
RefPtr<nsWebShellWindow> newWindow;
if (!aIsPrivate) {
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, nullptr, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);

mHiddenWindow.swap(newWindow);
} else {
// Create the hidden private window
chromeMask |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}

RefPtr<nsWebShellWindow> newWindow;
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, nullptr, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);
rv = JustCreateTopWindow(nullptr, url,
chromeMask, initialWidth, initialHeight,
true, nullptr, getter_AddRefs(newWindow));
NS_ENSURE_SUCCESS(rv, rv);

nsCOMPtr<nsIDocShell> docShell;
newWindow->GetDocShell(getter_AddRefs(docShell));
if (docShell) {
docShell->SetIsActive(false);
if (aIsPrivate) {
nsCOMPtr<nsIDocShell> docShell;
newWindow->GetDocShell(getter_AddRefs(docShell));
if (docShell) {
docShell->SetAffectPrivateSessionLifetime(false);
}
}

if (aIsPrivate) {
mHiddenPrivateWindow.swap(newWindow);
} else {
mHiddenWindow.swap(newWindow);
}

// RegisterTopLevelWindow(newWindow); -- Mac only

return NS_OK;
}

Expand Down

0 comments on commit a6dbf7e

Please sign in to comment.