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

[CLOSED] Fix for launching Chrome with temporary profile in OSX. #217

Open
core-ai-bot opened this issue Aug 17, 2021 · 30 comments
Open

[CLOSED] Fix for launching Chrome with temporary profile in OSX. #217

core-ai-bot opened this issue Aug 17, 2021 · 30 comments

Comments

@core-ai-bot
Copy link
Member

Issue by fungl164
Thursday Sep 26, 2013 at 20:59 GMT
Originally opened as adobe#339


Prevents Brackets from interfering with end-user sessions in Chrome (i.e. history, open tabs, etc.).

See related: adobe/brackets#2998.

This requires brackets pull request: adobe/brackets#5392


fungl164 included the following code: https://github.com/adobe/brackets-shell/pull/339/commits

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Friday Sep 27, 2013 at 16:01 GMT


@fungl164 Thanks for submitting this pull request! You'll need to agree to the Brackets CLA before I can merge this.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Friday Sep 27, 2013 at 16:39 GMT


@fungl164 This doesn't seem to work how I was expecting it to. On Windows, you can open a Chrome browser window and have some Tabs open in that window. Then in Brackets, when you start Live Development, it opens a second Chrome browser window.

On MacOS 10.8, Live Dev tries to open a new Tab in existing window, fails, and then prompts me to Relaunch Chrome.

With this code, can you open Live Dev in the scenario above without getting the Relaunch Chrome prompt? If so, is Live Dev opened in a new window, or just a new Tab?

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 00:37 GMT


@fungl164 I've been playing around with this and I can get it to work when I type in the args on the command line, but not in Brackets, so I guess it must have something to do with how the command is getting built in brackets-shell.

If you get a chance to work on this some more, we want the user data dir to go the app support folder, and use a different name to be consistent with other platforms, which needs to be quoted since there are spaces in the path, so something like:

--user-data-dir=\"" + ClientApp::AppGetSupportDirectory() + "/live-dev-profile\""

And one other flag for those that have a default browser other than Chrome:

--no-default-browser-check

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 13:27 GMT


@redmunds so I made a few changes to make chrome startup and terminate based on proper process ids (fungl164@8e0fa25). I've also added your comments as a separate commit (fungl164@44b8b79).

I still cannot get Brackets to issue a CloseLiveBrowser() call when clicking on the Live Dev icon. I believe its somewhere in the js code, but I don't know the proper place to put it. Once that's done, it should terminate correctly.

Disabling Live Dev from the toolbar just closes the tab but leaves the chrome instance running right now because of the missing call to CloseLiveBrowser(). To enable Live Dev, you'll need to close the second instance of Chrome and click the icon in Brackets.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 13:57 GMT


amended last commit to account for common profile path in process id look-up.
old -> fungl164@44b8b79
new -> fungl164@107ce80

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 14:44 GMT


@fungl164 Can you push your changes to the same branch so I can pull them and take a look?

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 15:37 GMT


@redmunds ok. try it now.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 16:09 GMT


Awesome! This is getting very close.

It's not critical that Chrome app stays open with no windows open because that's how it behaves now, but yes it would be nice. If you want to mess with it, the next function in the brackets-shell code is CloseLiveBrowser() if you want to try to close it from brackets-shell, or use NativeApp.closeLiveBrowser() in brackets.

The main problem I am seeing is that a Tab with the "interstitial" page (LiveDevelopment/launch.html) is staying open on the first launch. If no Chrome window is open, then the tab is in the live-dev-profile window. If there is already a default Chrome window open, then the Tab is in the default window. Any ideas on that?

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 16:17 GMT


Also, is --temp-profile necessary? I commented it out and it doesn't seem to have any effect.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 17:13 GMT


@redmunds --temp-profile AFAIK is only necessary and useful if no --user-data-dir is specified. Otherwise, chrome will attempt to use the current/last used profile with the corresponding state.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 19:04 GMT


@redmunds added fix for brackets source to call native impl of CloseLiveBrowser().
(see fungl164/brackets@7d9bff2)

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 20:27 GMT


@fungl164 This seems to work great! Brackets Mac users will be very happy about this. I'm going to bang on it a little more and make one more pass through the code.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 21:44 GMT


Found a bug:

  1. Start a default Chrome window
  2. Start Live Dev into a live-dev-profile Chrome window
  3. Stop Live Dev -- notice second instance of Chrome is still in taskbar
  4. Start Live Dev again

Results
New Tab is opened in default Chrome window, not live-dev-profile

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 21:54 GMT


@redmunds Hmmm. I can't replicate it over here. I works for me. Can you download the latest code and test with it?

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 22:02 GMT


also make sure you have the modifications I made to brackets src/LiveDevelopment/LiveDevelopment.js (fungl164/brackets@7d9bff2) installed.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 22:21 GMT


No, I did not see the change you made to the brackets repo. Please submit a pull request so I can test & then merge both pull requests together. Thanks.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Tuesday Oct 01, 2013 at 22:25 GMT


Done.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Tuesday Oct 01, 2013 at 23:42 GMT


The brackets repo change fixes the bug I reported above. Unfortunately, I am seeing some of the tests fail. Here's how to run them:

  1. Debug > Run Tests
  2. Click on the Integration tab
  3. Run the Live Development tests

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Wednesday Oct 02, 2013 at 00:08 GMT


Mine passes. Which tests are failing for you?
I'm using Brackets sprint 32 development build 0.32.0-0 (master d328b3a4c)

brackets-live-dev-tests

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Wednesday Oct 02, 2013 at 03:10 GMT


Just 1 test is consistently failing at the moment:

screen shot 2013-10-01 at 8 06 32 pm

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Thursday Oct 03, 2013 at 00:55 GMT


I found another bug:

  1. Close down all instances of Chrome
  2. From Brackets, start Live Dev
  3. In the Chrome window, File > New Tab to open another tab in that window
  4. Also in the Chrome window, File > New Window to open a new window
  5. In Brackets, stop Live Dev

Results:
All Chrome tabs and windows are closed.

Expected:
Only the tab with Live Dev is closed, so 2 Chrome windows remain open. This is how it works on Windows.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Thursday Oct 03, 2013 at 01:18 GMT


Well, that is expected. What's happening is that a call to Native.closeLiveBrowser() will terminate the browser session completely (including all tabs and windows) by terminating the process. What you're expecting is probably better handled in the JS code (e.g. close a tab), rather than requesting the native code to close down the live-dev browser session.

Note there is a side effect of just closing a tab. It means that the browser will remain in debug mode with and open port until closed (which could be construed as a security issue). Being that it is also working off a separate profile...the end user cannot and should not expect to have the browser state to be in sync with the non-debug enabled user profile. Do you agree?

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Thursday Oct 03, 2013 at 04:08 GMT


I discussed this with @gruehle before I logged it here, and we both thought Brackets closing what seem like unrelated browser tabs/windows is worse. Part of the problem is that there doesn't seem to be a way via the Chrome UI to open a new tab or window using the default Chrome profile. I'll see what the rest of the team thinks, but I would not expect Brackets to close something that it didn't open.

@core-ai-bot
Copy link
Member Author

Comment by MattSturgeon
Thursday Oct 03, 2013 at 09:04 GMT


Perhaps one of the flags that hides the ability to create new tabs (e.g. appmode) could act as a hacky workaround? This may also make it clearer that the Chrome window is related to brackets.

@core-ai-bot
Copy link
Member Author

Comment by redmunds
Thursday Oct 03, 2013 at 15:36 GMT


@MattSturgeon Thanks for joining the conversation! The only reason that I opened new tabs/windows in the live-dev-profile is because I couldn't figure out how to open them in the default profile -- which I think would be the usual intent. Is there any way to do that? Maybe it's caused by one of the flags we're using?

If disabling the ability to open tabs/windows using the live-dev-profile causes new windows to get opened in the default profile, then I think that's perfect.

Another thing we should do (but not required for this pull request) would be to create a custom skin for live-dev-profile to make it obvious that it's a window created by Brackets and you don't want to be creating new tabs/windows in it.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Thursday Oct 03, 2013 at 16:57 GMT


@redmunds I was thinking along the same lines of skinning. I'm all in favor of keeping things separate. It is the main reason for me getting the shell to behave this way. I don't want Live Dev to mess around with my normal browsing session.

I can alter the live-dev profile to my liking without consequences. Otherwise things start to get whacky and hacky. :)

@core-ai-bot
Copy link
Member Author

Comment by MattSturgeon
Thursday Oct 03, 2013 at 17:00 GMT


I had hoped that running with --app=URL would disable creating new tabs/windows but after testing on linux this doesn't seem to be the case. While the toolbars are hidden, Ctrl+T or Ctrl+W will still open a new window within the same session.

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Thursday Oct 03, 2013 at 17:17 GMT


Also, note that the LiveBrowser session I'm creating is a completely separate instance of Chrome that runs concurrently. This means not relaunching and not restoring the previous 1000+ windows/tabs I often have open during normal browsing for the sake of turn on the debug port.

That's the beauty of separation... :)

@core-ai-bot
Copy link
Member Author

Comment by MattSturgeon
Thursday Oct 03, 2013 at 17:26 GMT


How does enabling remote debugging work on windows?
Does it get enabled retrospectively on the active session? Does it automatically create a new session (without the need to use a separate data-dir)? Or does it restart if debugging does not get enabled?
Also how is a lost connection handled (e.g. when the embedded dev-tools are opened)?

@core-ai-bot
Copy link
Member Author

Comment by fungl164
Thursday Oct 03, 2013 at 17:33 GMT


All good questions. I haven't used windows in a couple of years, but I highly doubt it happens retrospectively.

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

No branches or pull requests

1 participant