Bug 930793 - Remove favor performance mode, r=avih,roc

--HG--
extra : rebase_source : a112b660baa240afd5f0022cd869c96b59418789
This commit is contained in:
Olli Pettay 2015-04-12 23:08:55 +03:00
Родитель 27729b2112
Коммит eb314fb48f
18 изменённых файлов: 57 добавлений и 130 удалений

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

@ -200,8 +200,6 @@
#include "nsIBrowserSearchService.h"
#endif
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#if defined(DEBUG_bryner) || defined(DEBUG_chb)
//#define DEBUG_DOCSHELL_FOCUS
#define DEBUG_PAGE_CACHE
@ -222,9 +220,6 @@ static bool gAddedPreferencesVarCache = false;
bool nsDocShell::sUseErrorPages = false;
// Number of documents currently loading
static int32_t gNumberOfDocumentsLoading = 0;
// Global count of existing docshells.
static int32_t gDocShellCount = 0;
@ -255,18 +250,6 @@ static PRLogModuleInfo* gDocShellLeakLog;
const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties";
static void
FavorPerformanceHint(bool aPerfOverStarvation)
{
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
if (appShell) {
appShell->FavorPerformanceHint(
aPerfOverStarvation,
Preferences::GetUint("docshell.event_starvation_delay_hint",
NS_EVENT_STARVATION_DELAY_HINT));
}
}
//*****************************************************************************
// <a ping> support
//*****************************************************************************
@ -7541,14 +7524,6 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
mIsExecutingOnLoadHandler = false;
mEODForCurrentDocument = true;
// If all documents have completed their loading
// favor native event dispatch priorities
// over performance
if (--gNumberOfDocumentsLoading == 0) {
// Hint to use normal native event dispatch priorities
FavorPerformanceHint(false);
}
}
/* Check if the httpChannel has any cache-control related response headers,
* like no-store, no-cache. If so, update SHEntry so that
@ -8678,12 +8653,6 @@ nsDocShell::RestoreFromHistory()
mSavingOldViewer = false;
mEODForCurrentDocument = false;
// Tell the event loop to favor plevents over user events, see comments
// in CreateContentViewer.
if (++gNumberOfDocumentsLoading == 1) {
FavorPerformanceHint(true);
}
if (oldCv && newCv) {
newCv->SetMinFontSize(minFontSize);
newCv->SetTextZoom(textZoom);
@ -9096,16 +9065,6 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType,
}
}
// Give hint to native plevent dispatch mechanism. If a document
// is loading the native plevent dispatch mechanism should favor
// performance over normal native event dispatch priorities.
if (++gNumberOfDocumentsLoading == 1) {
// Hint to favor performance for the plevent notification mechanism.
// We want the pages to load as fast as possible even if its means
// native messages might be starved.
FavorPerformanceHint(true);
}
if (onLocationChangeNeeded) {
FireOnLocationChange(this, aRequest, mCurrentURI, 0);
}

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

@ -201,7 +201,6 @@ nsContentSink::Init(nsIDocument* aDoc,
if (sEnablePerfMode != 0) {
mDynamicLowerValue = sEnablePerfMode == 1;
FavorPerformanceHint(!mDynamicLowerValue, 0);
}
return NS_OK;
@ -1408,15 +1407,6 @@ nsContentSink::DidProcessATokenImpl()
//----------------------------------------------------------------------
void
nsContentSink::FavorPerformanceHint(bool perfOverStarvation, uint32_t starvationDelay)
{
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
if (appShell)
appShell->FavorPerformanceHint(perfOverStarvation, starvationDelay);
}
void
nsContentSink::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
{
@ -1494,12 +1484,6 @@ nsContentSink::DropParserAndPerfHint(void)
// reference.
nsRefPtr<nsParserBase> kungFuDeathGrip(mParser.forget());
if (mDynamicLowerValue) {
// Reset the performance hint which was set to FALSE
// when mDynamicLowerValue was set.
FavorPerformanceHint(true, 0);
}
if (!mRunsToCompletion) {
mDocument->UnblockOnload(true);
}
@ -1537,7 +1521,6 @@ nsContentSink::WillParseImpl(void)
(currentTime - lastEventTime) < uint32_t(sInteractiveTime));
if (mDynamicLowerValue != newDynLower) {
FavorPerformanceHint(!newDynLower, 0);
mDynamicLowerValue = newDynLower;
}
}

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

@ -239,8 +239,6 @@ public:
static void NotifyDocElementCreated(nsIDocument* aDoc);
protected:
void
FavorPerformanceHint(bool perfOverStarvation, uint32_t starvationDelay);
inline int32_t GetNotificationInterval()
{

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

@ -65,7 +65,7 @@ function tests(aEnabled) {
expectSuccess([1000, 1000.1]);
// The following loop shouldn't cause us to crash. See bug 701716.
for (var i = 0; i < 10000; i++) {
for (var i = 0; i < 1000; i++) {
navigator.vibrate([100, 100]);
}
ok(true, "Didn't crash after issuing a lot of vibrate() calls.");

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

@ -51,9 +51,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602
var firstCall = !unLockedCoords;
if (!firstCall) {
todo(false, "mousemove is fired twice.");
} else {
isUnlocked = !document.mozPointerLockElement;
}
isUnlocked = !document.mozPointerLockElement;
unLockedCoords = {
screenX: e.screenX,
screenY: e.screenY,

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

@ -1722,7 +1722,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mViewManagerFlushIsPending = false;
nsRefPtr<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
vm->ProcessPendingUpdates();
vm->ProcessPendingUpdates(nsViewManager::eTrySyncUpdate);
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
printf_stderr("Ending ProcessPendingUpdates\n");

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

@ -677,7 +677,7 @@ void nsViewManager::WillPaintWindow(nsIWidget* aWidget)
LayerManager *manager = aWidget->GetLayerManager();
if (view &&
(view->ForcedRepaint() || !manager->NeedsWidgetInvalidation())) {
ProcessPendingUpdates();
ProcessPendingUpdates(eNoSyncUpdate);
// Re-get the view pointer here since the ProcessPendingUpdates might have
// destroyed it during CallWillPaintOnObservers.
view = nsView::GetViewFor(aWidget);
@ -1060,10 +1060,10 @@ nsViewManager::IsPainting(bool& aIsPainting)
}
void
nsViewManager::ProcessPendingUpdates()
nsViewManager::ProcessPendingUpdates(UpdatingMode aMode)
{
if (!IsRootVM()) {
RootViewManager()->ProcessPendingUpdates();
RootViewManager()->ProcessPendingUpdates(aMode);
return;
}
@ -1075,6 +1075,14 @@ nsViewManager::ProcessPendingUpdates()
ProcessPendingUpdatesForView(mRootView, true);
}
if (aMode == eTrySyncUpdate) {
nsCOMPtr<nsIWidget> w;
GetRootWidget(getter_AddRefs(w));
if (w) {
w->Update();
}
}
}
void

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

@ -303,11 +303,16 @@ public:
*/
static nsView* GetDisplayRootFor(nsView* aView);
enum UpdatingMode {
eNoSyncUpdate,
eTrySyncUpdate
};
/**
* Flush the accumulated dirty region to the widget and update widget
* geometry.
*/
void ProcessPendingUpdates();
void ProcessPendingUpdates(UpdatingMode aMode);
/**
* Just update widget geometry without flushing the dirty region

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

@ -1697,6 +1697,14 @@ nsWindow::Invalidate(const nsIntRect &aRect)
return NS_OK;
}
void
nsWindow::Update()
{
if (!ShouldUseOffMainThreadCompositing() && mGdkWindow) {
gdk_window_process_updates(mGdkWindow, true);
}
}
void*
nsWindow::GetNativeData(uint32_t aDataType)
{

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

@ -133,6 +133,7 @@ public:
NS_IMETHOD SetCursor(imgIContainer* aCursor,
uint32_t aHotspotX, uint32_t aHotspotY) override;
NS_IMETHOD Invalidate(const nsIntRect &aRect) override;
virtual void Update() override;
virtual void* GetNativeData(uint32_t aDataType) override;
void SetNativeData(uint32_t aDataType, uintptr_t aVal) override;
NS_IMETHOD SetTitle(const nsAString& aTitle) override;

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

@ -25,11 +25,7 @@ nsBaseAppShell::nsBaseAppShell()
: mSuspendNativeCount(0)
, mEventloopNestingLevel(0)
, mBlockedWait(nullptr)
, mFavorPerf(0)
, mNativeEventPending(false)
, mStarvationDelay(0)
, mSwitchTime(0)
, mLastNativeEventTime(0)
, mEventloopNestingState(eEventloopNone)
, mRunning(false)
, mExiting(false)
@ -179,20 +175,6 @@ nsBaseAppShell::Exit(void)
return NS_OK;
}
NS_IMETHODIMP
nsBaseAppShell::FavorPerformanceHint(bool favorPerfOverStarvation,
uint32_t starvationDelay)
{
mStarvationDelay = PR_MillisecondsToInterval(starvationDelay);
if (favorPerfOverStarvation) {
++mFavorPerf;
} else {
--mFavorPerf;
mSwitchTime = PR_IntervalNow();
}
return NS_OK;
}
NS_IMETHODIMP
nsBaseAppShell::SuspendNative()
{
@ -253,9 +235,6 @@ nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal *thr, bool mayWait,
OnDispatchedEvent(thr); // in case we blocked it earlier
}
PRIntervalTime start = PR_IntervalNow();
PRIntervalTime limit = THREAD_EVENT_STARVATION_LIMIT;
// Unblock outer nested wait loop (below).
if (mBlockedWait)
*mBlockedWait = false;
@ -271,21 +250,7 @@ nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal *thr, bool mayWait,
// NativeEventCallback to process gecko events.
mProcessedGeckoEvents = false;
if (mFavorPerf <= 0 && start > mSwitchTime + mStarvationDelay) {
// Favor pending native events
PRIntervalTime now = start;
bool keepGoing;
do {
mLastNativeEventTime = now;
keepGoing = DoProcessNextNativeEvent(false, recursionDepth);
} while (keepGoing && ((now = PR_IntervalNow()) - start) < limit);
} else {
// Avoid starving native events completely when in performance mode
if (start - mLastNativeEventTime > limit) {
mLastNativeEventTime = start;
DoProcessNextNativeEvent(false, recursionDepth);
}
}
DoProcessNextNativeEvent(false, recursionDepth);
while (!NS_HasPendingEvents(thr) && !mProcessedGeckoEvents) {
// If we have been asked to exit from Run, then we should not wait for
@ -294,7 +259,6 @@ nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal *thr, bool mayWait,
if (mExiting)
mayWait = false;
mLastNativeEventTime = PR_IntervalNow();
if (!DoProcessNextNativeEvent(mayWait, recursionDepth) || !mayWait)
break;
}

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

@ -122,11 +122,7 @@ private:
* have been consumed by the inner event loop(s).
*/
bool *mBlockedWait;
int32_t mFavorPerf;
mozilla::Atomic<bool> mNativeEventPending;
PRIntervalTime mStarvationDelay;
PRIntervalTime mSwitchTime;
PRIntervalTime mLastNativeEventTime;
enum EventloopNestingState {
eEventloopNone, // top level thread execution
eEventloopXPCOM, // innermost native event loop is ProcessNextNativeEvent

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

@ -12,7 +12,7 @@ interface nsIRunnable;
* Interface for the native event system layer. This interface is designed
* to be used on the main application thread only.
*/
[uuid(2d10ca53-f143-439a-bb2e-c1fbc71f6a05)]
[uuid(78dc2b13-5de6-42f3-af57-2535f7fdb93e)]
interface nsIAppShell : nsISupports
{
/**
@ -25,24 +25,6 @@ interface nsIAppShell : nsISupports
*/
void exit();
/**
* Give hint to native event queue notification mechanism. If the native
* platform needs to tradeoff performance vs. native event starvation this
* hint tells the native dispatch code which to favor. The default is to
* prevent native event starvation.
*
* Calls to this function may be nested. When the number of calls that pass
* PR_TRUE is subtracted from the number of calls that pass PR_FALSE is
* greater than 0, performance is given precedence over preventing event
* starvation.
*
* The starvationDelay arg is only used when favorPerfOverStarvation is
* PR_FALSE. It is the amount of time in milliseconds to wait before the
* PR_FALSE actually takes effect.
*/
void favorPerformanceHint(in boolean favorPerfOverStarvation,
in unsigned long starvationDelay);
/**
* Suspends the use of additional platform-specific methods (besides the
* nsIAppShell->run() event loop) to run Gecko events on the main

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

@ -114,8 +114,8 @@ typedef void* nsNativeWidget;
#define NS_NATIVE_PLUGIN_ID 105
#define NS_IWIDGET_IID \
{ 0x316E4600, 0x15DB, 0x47AE, \
{ 0xBF, 0xE4, 0x5B, 0xCD, 0xFF, 0x80, 0x80, 0x83 } };
{ 0x7a4ece50, 0x5c52, 0x47c2, \
{ 0x8c, 0x9e, 0x32, 0xd2, 0x5a, 0x27, 0x53, 0x34 } }
/*
* Window shadow styles
@ -1503,6 +1503,11 @@ class nsIWidget : public nsISupports {
*/
NS_IMETHOD Invalidate(const nsIntRect & aRect) = 0;
/**
* Widget implementation may support synchronous painting.
*/
virtual void Update() { }
enum LayerManagerPersistence
{
LAYER_MANAGER_CURRENT = 0,

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

@ -2826,6 +2826,14 @@ NS_METHOD nsWindow::Invalidate(const nsIntRect & aRect)
return NS_OK;
}
void
nsWindow::Update()
{
if (!ShouldUseOffMainThreadCompositing() && mWnd) {
::UpdateWindow(mWnd);
}
}
NS_IMETHODIMP
nsWindow::MakeFullScreen(bool aFullScreen, nsIScreen* aTargetScreen)
{

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

@ -134,6 +134,7 @@ public:
bool aUpdateNCArea = false,
bool aIncludeChildren = false);
NS_IMETHOD Invalidate(const nsIntRect & aRect);
virtual void Update() override;
virtual void* GetNativeData(uint32_t aDataType);
virtual void FreeNativeData(void * data, uint32_t aDataType);
NS_IMETHOD SetTitle(const nsAString& aTitle);

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

@ -1182,6 +1182,14 @@ MetroWidget::Invalidate(bool aEraseBackground,
return NS_OK;
}
void
MetroWidget::Update()
{
if (!ShouldUseOffMainThreadCompositing() && mWnd) {
::UpdateWindow(mWnd);
}
}
NS_IMETHODIMP
MetroWidget::Invalidate(const nsIntRect & aRect)
{

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

@ -110,6 +110,7 @@ public:
bool aUpdateNCArea = false,
bool aIncludeChildren = false);
NS_IMETHOD Invalidate(const nsIntRect & aRect);
virtual void Update() override;
NS_IMETHOD DispatchEvent(mozilla::WidgetGUIEvent* aEvent,
nsEventStatus& aStatus);
NS_IMETHOD ConstrainPosition(bool aAllowSlop, int32_t *aX, int32_t *aY);