bug 744519 - mplement memory-pressure flag to react quicker to memory pressure, without waiting for event loop r=gsvelto

This commit is contained in:
Brad Lassey 2013-11-27 06:52:05 -05:00
parent 8b93cea2da
commit e9b56df61d
4 changed files with 28 additions and 3 deletions

View File

@ -199,6 +199,7 @@ public class GeckoAppShell
}
public static native Message getNextMessageFromQueue(MessageQueue queue);
public static native void onSurfaceTextureFrameAvailable(Object surfaceTexture, int id);
public static native void dispatchMemoryPressure();
public static void registerGlobalExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

View File

@ -152,7 +152,7 @@ class MemoryMonitor extends BroadcastReceiver {
if (level >= MEMORY_PRESSURE_MEDIUM) {
//Only send medium or higher events because that's all that is used right now
if (GeckoThread.checkLaunchState(GeckoThread.LaunchState.GeckoRunning)) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createLowMemoryEvent(level));
GeckoAppShell.dispatchMemoryPressure();
}
Favicons.clearMemCache();

View File

@ -96,6 +96,25 @@ Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(JNIEnv * arg
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure_t)(JNIEnv *, jclass);
static Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure_t f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure;
extern "C" NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(JNIEnv * arg0, jclass arg1) {
if (!f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure) {
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
"JNI Function called before it was loaded");
return ;
}
f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(arg0, arg1);
}
#endif
#ifdef JNI_BINDINGS
xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure", &f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure);
#endif
#ifdef JNI_STUBS
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash_t)(JNIEnv *, jclass, jstring);
static Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash_t f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash;
extern "C" NS_EXPORT void JNICALL

View File

@ -41,8 +41,7 @@
#include "nsPluginInstanceOwner.h"
#include "nsSurfaceTexture.h"
#include "GeckoProfiler.h"
#include "GeckoProfiler.h"
#include "nsMemoryPressure.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -839,6 +838,12 @@ Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(JNIEnv* jenv
st->NotifyFrameAvailable();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(JNIEnv* jenv, jclass)
{
NS_DispatchMemoryPressure(MemPressure_New);
}
NS_EXPORT jdouble JNICALL
Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime(JNIEnv *jenv, jclass jc)
{