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

Avoid rebooting and rebuilding for certain type of restarts #424

Merged
merged 5 commits into from
Jul 8, 2024

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Jul 5, 2024

This PR changes the way we handle restarts / reloads.

Before, when fast-refresh wasn't possible, we'd use selectDevice flow, which always kills the simulator process, restarts it, starts new preview etc. This tend to take long and definitely much longer than needed when we only want the app process to be restarted.

An example when this scenario occurs frequently is when updating privacy permissions. In that case, the app process is killed by the system, and we need to restart it. Rebooting emulator in such a case is unnecessary.

The new restart flow now looks as follows:

  • unless force rebuild is requested (in which case we restart everything and also rebuild the app) we follow the procedure below:
  • we check if fast-refresh can be performed – for that we test if devtools connection is active which means that the app process is connected to devtools server
  • if not, we now try restarting the app process, we reuse the existing device and build if possible. If any of that doesn't work or is stale, this will trigger an exception and we will move to the next phase
  • finally, if the above fails, we go back to the select-device flow, which resets the simulator and build

Test plan:
this has been tested on top of permissions PR where I check that the app process restart is performed after resetting permissions.

@kmagiera kmagiera requested a review from jakub-gonet July 5, 2024 12:28
Copy link

vercel bot commented Jul 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-ide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 8, 2024 0:51am

Copy link
Member

@jakub-gonet jakub-gonet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I must admit that launching/restarting/soft-restarting logic is getting gnarly.

@kmagiera kmagiera merged commit a34b0ae into main Jul 8, 2024
3 checks passed
@kmagiera kmagiera deleted the kmagiera/smarter-restart branch July 8, 2024 13:00
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.

2 participants