diff --git a/widget/nsBaseAppShell.cpp b/widget/nsBaseAppShell.cpp index 5ea4b9e2e9f8..632f38478c90 100644 --- a/widget/nsBaseAppShell.cpp +++ b/widget/nsBaseAppShell.cpp @@ -26,10 +26,8 @@ nsBaseAppShell::nsBaseAppShell() : mSuspendNativeCount(0), mEventloopNestingLevel(0), mBlockedWait(nullptr), - mFavorPerf(0), mNativeEventPending(false), - mStarvationDelay(0), - mSwitchTime(0), + mGeckoTaskBurstStartTime(0), mLastNativeEventTime(0), mEventloopNestingState(eEventloopNone), mRunning(false), @@ -165,14 +163,9 @@ nsBaseAppShell::Exit(void) { } NS_IMETHODIMP -nsBaseAppShell::FavorPerformanceHint(bool favorPerfOverStarvation, - uint32_t starvationDelay) { - mStarvationDelay = PR_MillisecondsToInterval(starvationDelay); - if (favorPerfOverStarvation) { - ++mFavorPerf; - } else { - --mFavorPerf; - mSwitchTime = PR_IntervalNow(); +nsBaseAppShell::GeckoTaskBurst() { + if (mGeckoTaskBurstStartTime == 0) { + mGeckoTaskBurstStartTime = PR_IntervalNow(); } return NS_OK; } @@ -246,7 +239,9 @@ nsBaseAppShell::OnProcessNextEvent(nsIThreadInternal* thr, bool mayWait) { // NativeEventCallback to process gecko events. mProcessedGeckoEvents = false; - if (mFavorPerf <= 0 && start > mSwitchTime + mStarvationDelay) { + // Content processes always priorize gecko events. + if (!XRE_IsContentProcess() && (start > (mGeckoTaskBurstStartTime + limit))) { + mGeckoTaskBurstStartTime = 0; // Favor pending native events PRIntervalTime now = start; bool keepGoing; diff --git a/widget/nsBaseAppShell.h b/widget/nsBaseAppShell.h index 6f7bd1893ac5..fabc0e188afe 100644 --- a/widget/nsBaseAppShell.h +++ b/widget/nsBaseAppShell.h @@ -97,10 +97,8 @@ class nsBaseAppShell : public nsIAppShell, * have been consumed by the inner event loop(s). */ bool* mBlockedWait; - int32_t mFavorPerf; mozilla::Atomic mNativeEventPending; - PRIntervalTime mStarvationDelay; - PRIntervalTime mSwitchTime; + PRIntervalTime mGeckoTaskBurstStartTime; PRIntervalTime mLastNativeEventTime; enum EventloopNestingState { eEventloopNone, // top level thread execution diff --git a/widget/nsIAppShell.idl b/widget/nsIAppShell.idl index 14028b15d8c6..f2ea8ab1665f 100644 --- a/widget/nsIAppShell.idl +++ b/widget/nsIAppShell.idl @@ -35,22 +35,11 @@ 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. + * Ask the native event queue notification mechanism to favor Gecko tasks + * (instead of native tasks) for a short while. (Content processes always + * favor Gecko tasks.) */ - void favorPerformanceHint(in boolean favorPerfOverStarvation, - in unsigned long starvationDelay); + void geckoTaskBurst(); /** * Suspends the use of additional platform-specific methods (besides the