VIT-7771: Fix deprioritized resources not making forward progress in some environments #253
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.
React Native does not appear to use UIScene.
As a result, the app lifecycle callouts appear to behave quite differently. The
appWillEnterForeground
callout we expected afterappDidFinishLaunching
does not happen.This causes our
AppStateTracker
to be stuck instate = appLaunching
instead of progressing tostate = foreground
shortly after app launch. This in turn has a knock-on effect on (historical stage) deprioritized resources. In 1.2.0-1.2.10, primary avenue of deprioritised resource re-attempts (scheduleDeprioritizedResourceRetries()
) are only allowed to run whenstate = foreground
. This resulted in deprioritized resources having a very high chance of being stuck deprioritized and never re-evaluated.This PR:
schedules a
UIApplication.applicationState
check one runloop iteration afterappDidFinishLaunching
.AppStateTracker
will transition tostate = foreground
in both UIScene-disabled and UIScene-enabled apps.scheduleDeprioritizedResourceRetries()
will function as expected for apps w/o scene support, e.g., the main bulk of React Native projects.Expand the scope of resource rescue of
scheduleUnnotifiedResourceRescue
to include resources stuck instarted
anddeprioritized
states.AppStateTracker
state. So this serves as a secondary avenue to trigger deprioritised resources.