Fix for UIApplicationDidReceiveMemoryWarningNotification not being obeyed on iOS #37973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Prior to 0.69, an RN app receiving the
UIApplicationDidReceiveMemoryWarningNotification
notification resulted in RN performing a GC on the JSC. Since 0.69 this has not worked, this PR fixes the issue.Before 0.69 this was handled via a hardcoded memory pressure level:
react-native/React/CxxBridge/RCTCxxBridge.mm
Line 362 in c5c1798
(It seems like the levels are an Android concept - see https://developer.android.com/reference/android/content/ComponentCallbacks2#constants_1)
In commit 0916df9 it was changed to run from a constant which could be reconfigured but a mistake (return type of
BOOL
rather thanint
) was resulting in the intended default memory pressure level of 15 (same as the old hardcoded value) being changed to 1 when it was passed on tohandleMemoryPressure
.Changelog:
[IOS] [FIXED] - UIApplicationDidReceiveMemoryWarningNotification has not been obeyed on iOS since RN 0.69
Test Plan:
Tested manually via the Simulator using Debug -> Simulate Memory Warning and monitoring the console output of the app.
Before fix:
With fix (and also the same output for the latest 0.68 tag in the repo):