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

feat: reuse opening tab in chromium browsers when start dev server #10485

Merged
merged 1 commit into from Oct 18, 2022

Conversation

nvh95
Copy link
Contributor

@nvh95 nvh95 commented Oct 16, 2022

Description

Currently, if a mac users use Google Chrome, when they start the dev server, vite will try to reuse an opening tab (using AppleScript).

However, many developers they use other Chromium-based browsers such as Chrome Dev, Chrome Beta, Microsoft Edge... This PR is to support reuse an existing tab for some common Chromium browser

Reference:

Additional context

This is a "nice to have" feature of vite for mac users. We only need to test it on mac (which I already did)


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added the p2-nice-to-have Not breaking anything but nice to have (priority) label Oct 17, 2022
@bluwy bluwy merged commit 1a2e7a8 into vitejs:main Oct 18, 2022
@nvh95 nvh95 deleted the reuse-tab-chromium branch October 18, 2022 05:15
@ArnaudBarre
Copy link
Member

Hi thanks for improving the browser support for Vite.

I want to point out that is not totally free, even if the Apple script is executed once the ps cax | grep is done for each browser, and this is around ~50ms on my Intel mac, without the nodejs overhead. A more precise benchmark could be done, but this is PR would adds around ~150ms to relaunch the browser for current user of Google Chrome (and ~350ms if it's not running).

I think doing a more complex grep in one go and then adding a post filtering in js to know which one effectively match would make this feature almost invisible for current users.

Screenshot 2022-10-20 at 16 54 13

@bluwy
Copy link
Member

bluwy commented Oct 21, 2022

Thanks for investigating the perf implications of this @ArnaudBarre! Would you like to submit a PR with the suggestion? I think it would benefit create-react-app too

@ArnaudBarre
Copy link
Member

Yes I can do it this evening

@ArnaudBarre
Copy link
Member

@bluwy can you look at the suggested fix?

I just updated a repo to 3.2 and saw a big jump in server start due to that.

Profiles before/after for Chrome already opened:
Screenshot 2022-11-02 at 00 55 58

Screenshot 2022-11-02 at 00 54 08

@bluwy
Copy link
Member

bluwy commented Nov 2, 2022

Ah my bad I miss your PR, checking that out now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants