Add MC to test disabling React Native invalidation under memory pressure

Summary: Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D35732504

fbshipit-source-id: d81d6ddefc98d1e73be697c3eef8a2c90104658c
This commit is contained in:
Paige Sun
2022-04-20 10:59:57 -07:00
committed by Facebook GitHub Bot
parent c5c17985da
commit 0916df9951
3 changed files with 45 additions and 1 deletions
+12
View File
@@ -21,3 +21,15 @@ RCT_EXTERN void RCTExperimentSetPreemptiveViewAllocationDisabled(BOOL value);
*/
RCT_EXTERN BOOL RCTGetDispatchW3CPointerEvents(void);
RCT_EXTERN void RCTSetDispatchW3CPointerEvents(BOOL value);
/*
* Memory Pressure Unloading
*/
RCT_EXTERN BOOL RCTGetDisableBridgeMemoryPressureUnload(void);
RCT_EXTERN void RCTSetDisableBridgeMemoryPressureUnload(BOOL value);
/*
* Memory Pressure Unloading Level
*/
RCT_EXTERN BOOL RCTGetMemoryPressureUnloadLevel(void);
RCT_EXTERN void RCTSetMemoryPressureUnloadLevel(int value);
+31
View File
@@ -39,3 +39,34 @@ void RCTSetDispatchW3CPointerEvents(BOOL value)
{
RCTDispatchW3CPointerEvents = value;
}
/*
* Memory Pressure Unloading
*/
static BOOL RCTDisableBridgeMemoryPressureUnload = NO;
BOOL RCTGetDisableBridgeMemoryPressureUnload()
{
return RCTDisableBridgeMemoryPressureUnload;
}
void RCTSetDisableBridgeMemoryPressureUnload(BOOL value)
{
RCTDisableBridgeMemoryPressureUnload = value;
}
/*
* Memory Pressure Unloading Level for experimentation only.
* Default is 15, which is TRIM_MEMORY_RUNNING_CRITICAL.
*/
static int RCTMemoryPressureUnloadLevel = 15;
BOOL RCTGetMemoryPressureUnloadLevel()
{
return RCTMemoryPressureUnloadLevel;
}
void RCTSetMemoryPressureUnloadLevel(int value)
{
RCTMemoryPressureUnloadLevel = value;
}
+2 -1
View File
@@ -359,7 +359,8 @@ struct RCTInstanceCallback : public InstanceCallback {
// in case if some other tread resets it.
auto reactInstance = _reactInstance;
if (reactInstance) {
reactInstance->handleMemoryPressure(15 /* TRIM_MEMORY_RUNNING_CRITICAL */);
int unloadLevel = RCTGetMemoryPressureUnloadLevel();
reactInstance->handleMemoryPressure(unloadLevel);
}
}