Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIT-7771: Fix deprioritized resources not making forward progress in some environments #253

Conversation

andersio
Copy link
Contributor

@andersio andersio commented Nov 8, 2024

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 after appDidFinishLaunching does not happen.

This causes our AppStateTracker to be stuck in state = appLaunching instead of progressing to state = 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 when state = foreground. This resulted in deprioritized resources having a very high chance of being stuck deprioritized and never re-evaluated.

This PR:

  1. schedules a UIApplication.applicationState check one runloop iteration after appDidFinishLaunching.

    • This ensures that AppStateTracker will transition to state = foreground in both UIScene-disabled and UIScene-enabled apps.
    • This in turn ensures that scheduleDeprioritizedResourceRetries() will function as expected for apps w/o scene support, e.g., the main bulk of React Native projects.
  2. Expand the scope of resource rescue of scheduleUnnotifiedResourceRescue to include resources stuck in started and deprioritized states.

    • Note that the resource rescue runs irrespective of the AppStateTracker state. So this serves as a secondary avenue to trigger deprioritised resources.

Copy link
Contributor Author

andersio commented Nov 8, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @andersio and the rest of your teammates on Graphite Graphite

@andersio andersio force-pushed the 11-08-vit-7771_fix_deprioritized_resources_not_making_forward_progress_in_some_environments branch from 6ac3e0a to 8cb4230 Compare November 8, 2024 20:06
@andersio andersio mentioned this pull request Nov 8, 2024
Copy link
Contributor Author

andersio commented Nov 8, 2024

Merge activity

  • Nov 8, 3:15 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Nov 8, 3:15 PM EST: A user merged this pull request with Graphite.

@andersio andersio merged commit 65f1f8e into main Nov 8, 2024
4 checks passed
@andersio andersio deleted the 11-08-vit-7771_fix_deprioritized_resources_not_making_forward_progress_in_some_environments branch November 9, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant