зеркало из https://github.com/mozilla/gecko-dev.git
Bug 823610: Make discarding GL contexts of foreground pages on memory pressure pref-able, and pref off for b2g. r=jgilbert,jlebar
This commit is contained in:
Родитель
ec8c1158f6
Коммит
3b5768770c
|
@ -615,3 +615,7 @@ pref("wap.UAProf.tagname", "x-wap-profile");
|
|||
|
||||
// Wait up to this much milliseconds when orientation changed
|
||||
pref("layers.orientation.sync.timeout", 1000);
|
||||
|
||||
// Don't discard WebGL contexts for foreground apps on memory
|
||||
// pressure.
|
||||
pref("webgl.can-lose-context-in-foreground", false);
|
||||
|
|
|
@ -45,12 +45,14 @@
|
|||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/WebGLRenderingContextBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/ipc/ProcessPriorityManager.h"
|
||||
|
||||
#include "Layers.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gl;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::ipc;
|
||||
using namespace mozilla::layers;
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -63,7 +65,10 @@ WebGLMemoryPressureObserver::Observe(nsISupports* aSubject,
|
|||
|
||||
bool wantToLoseContext = true;
|
||||
|
||||
if (!nsCRT::strcmp(aSomeData, NS_LITERAL_STRING("heap-minimize").get()))
|
||||
if (!mContext->mCanLoseContextInForeground && CurrentProcessIsForeground())
|
||||
wantToLoseContext = false;
|
||||
else if (!nsCRT::strcmp(aSomeData,
|
||||
NS_LITERAL_STRING("heap-minimize").get()))
|
||||
wantToLoseContext = mContext->mLoseContextOnHeapMinimize;
|
||||
|
||||
if (wantToLoseContext)
|
||||
|
@ -179,6 +184,7 @@ WebGLContext::WebGLContext()
|
|||
mContextStatus = ContextStable;
|
||||
mContextLostErrorSet = false;
|
||||
mLoseContextOnHeapMinimize = false;
|
||||
mCanLoseContextInForeground = true;
|
||||
|
||||
mAlreadyGeneratedWarnings = 0;
|
||||
mAlreadyWarnedAboutFakeVertexAttrib0 = false;
|
||||
|
|
|
@ -843,6 +843,7 @@ protected:
|
|||
bool mHasRobustness;
|
||||
bool mIsMesa;
|
||||
bool mLoseContextOnHeapMinimize;
|
||||
bool mCanLoseContextInForeground;
|
||||
|
||||
template<typename WebGLObjectType>
|
||||
void DeleteWebGLObjectsArray(nsTArray<WebGLObjectType>& array);
|
||||
|
|
|
@ -858,6 +858,7 @@ WebGLContext::InitAndValidateGL()
|
|||
mMinCapability = Preferences::GetBool("webgl.min_capability_mode", false);
|
||||
mDisableExtensions = Preferences::GetBool("webgl.disable-extensions", false);
|
||||
mLoseContextOnHeapMinimize = Preferences::GetBool("webgl.lose-context-on-heap-minimize", false);
|
||||
mCanLoseContextInForeground = Preferences::GetBool("webgl.can-lose-context-in-foreground", true);
|
||||
|
||||
mActiveTexture = 0;
|
||||
mWebGLError = LOCAL_GL_NO_ERROR;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/dom/ipc/ProcessPriorityManager.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
|
@ -26,6 +27,7 @@
|
|||
#include "nsIDOMEventTarget.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "StaticPtr.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <process.h>
|
||||
|
@ -42,6 +44,8 @@ namespace ipc {
|
|||
|
||||
namespace {
|
||||
static bool sInitialized = false;
|
||||
class ProcessPriorityManager;
|
||||
static StaticRefPtr<ProcessPriorityManager> sManager;
|
||||
|
||||
// Some header defines a LOG macro, but we don't want it here.
|
||||
#ifdef LOG
|
||||
|
@ -127,6 +131,8 @@ public:
|
|||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIDOMEVENTLISTENER
|
||||
|
||||
ProcessPriority GetPriority() const { return mProcessPriority; }
|
||||
|
||||
private:
|
||||
void SetPriority(ProcessPriority aPriority);
|
||||
void OnContentDocumentGlobalCreated(nsISupports* aOuterWindow);
|
||||
|
@ -389,9 +395,15 @@ InitProcessPriorityManager()
|
|||
return;
|
||||
}
|
||||
|
||||
// This object is held alive by the observer service.
|
||||
nsRefPtr<ProcessPriorityManager> mgr = new ProcessPriorityManager();
|
||||
mgr->Init();
|
||||
sManager = new ProcessPriorityManager();
|
||||
sManager->Init();
|
||||
ClearOnShutdown(&sManager);
|
||||
}
|
||||
|
||||
bool
|
||||
CurrentProcessIsForeground()
|
||||
{
|
||||
return sManager->GetPriority() >= PROCESS_PRIORITY_FOREGROUND;
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
|
|
|
@ -26,6 +26,13 @@ namespace ipc {
|
|||
*/
|
||||
void InitProcessPriorityManager();
|
||||
|
||||
/**
|
||||
* True iff the current process has foreground or higher priority as
|
||||
* computed by DOM visibility. The returned answer may not match the
|
||||
* actual OS process priority, for short intervals.
|
||||
*/
|
||||
bool CurrentProcessIsForeground();
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -70,6 +70,9 @@ typedef Observer<SwitchEvent> SwitchObserver;
|
|||
enum ProcessPriority {
|
||||
PROCESS_PRIORITY_BACKGROUND,
|
||||
PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
|
||||
// Any priority greater than or equal to FOREGROUND is considered
|
||||
// "foreground" for the purposes of priority testing, for example
|
||||
// CurrentProcessIsForeground().
|
||||
PROCESS_PRIORITY_FOREGROUND,
|
||||
PROCESS_PRIORITY_MASTER,
|
||||
NUM_PROCESS_PRIORITY
|
||||
|
|
|
@ -3706,6 +3706,7 @@ pref("webgl.prefer-16bpp", false);
|
|||
pref("webgl.default-no-alpha", false);
|
||||
pref("webgl.force-layers-readback", false);
|
||||
pref("webgl.lose-context-on-heap-minimize", false);
|
||||
pref("webgl.can-lose-context-in-foreground", true);
|
||||
|
||||
// Stagefright prefs
|
||||
pref("stagefright.force-enabled", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче