qutebrowser / qutebrowser

A keyboard-driven, vim-like browser based on Python and Qt.
https://www.qutebrowser.org/
GNU General Public License v3.0
9.44k stars 1.01k forks source link

Contextual identities / Firefox containers #4102

Open The-Compiler opened 5 years ago

The-Compiler commented 5 years ago

Since this came up once or twice in the past, I'd like to collect some thoughts on Firefox containers:

What we could do (at least for QtWebEngine, not sure about QtWebKit off-hand) is adding something like --profile work or whatever to :open, which would act similarly to --private (i.e. open a new window with that profile/context associated). Note the same thing is possible by using multiple instances with different basedirs and linked configs, but it's a bit of a mess.

Maybe that could also be on a per-tab basis. However, the same considerations as in #2327 come into play, so I think I'd rather not.

What we can't do is switch profiles after a tab has been opened, i.e. we can't assign a URL to a profile and switch back and forth like Firefox can.

ciampolo commented 5 years ago

What we can't do is switch profiles after a tab has been opened, i.e. we can't assign a URL to a profile and switch back and forth like Firefox can.

This is the exact reason why Containers in Firefox are so wonderful though. Any tab (or domain) gets assigned a specific context. That tab can't break out of that context and they can be all in the same window.

I wonder why the engine used and supported by Google does not have a functionality that could harm their own business model

J-Lentz commented 5 years ago

I'd love to see this feature added to qutebrowser. Personally, I have no issue with containers being fixed to windows at the time the window is opened. If these containers were to encompass history as well as persistent web data, then perhaps it would be elegant to re-conceptualize private browsing as opening a "one-time-use" container.

Taking this a step further, perhaps select settings (or all settings) could also be made container-specific. This would be useful for both the privacy use-case (e.g., a container that's configured for Tor or a VPN) and the use-case where a separate container is used for work.

The-Compiler commented 5 years ago

@twosheds-jackson Also see #2314 which talks about per-window settings in general.

jgkamat commented 5 years ago

What we can't do is switch profiles after a tab has been opened, i.e. we can't assign a URL to a profile and switch back and forth like Firefox can.

This is the exact reason why Containers in Firefox are so wonderful though. Any tab (or domain) gets assigned a specific context. That tab can't break out of that context and they can be all in the same window.

This is really hacky but we might be able to do something like preventing the user from navigating to other urls, or destroying the tab (or just the webview) and creating a new one every time the domain changes.

If we could make that work, we might be able to fit profiles into the same 'per-domain' framework as the rest of the settings...

The-Compiler commented 5 years ago

but we might be able to do something like preventing the user from navigating to other urls

I'd rather just make it clear (via the UI) which context they're using to open the page, and let them decide for themselves :wink:

or destroying the tab (or just the webview) and creating a new one every time the domain changes.

That sounds like a recipe for too much trouble :wink:

pjvds commented 3 years ago

It would be awesome to see this coming to Qutebrowser.

markstos commented 3 years ago

There's also qutebrowser-profile. It simply allows you to launch profiles with different history, cookies and session data but a shared configuration. It does not force loading a particular domain into a particular profile. But on the upside, it's easy to implement.

Another interesting reference might be Open in Firefox - Chrome Web Store. In particular, it has a "allowlist" mode, where only certain URLs will be loaded by the current browser/profile. Other links would be redirected to an alternate profile. That be a helpful concept if you have just two containers, but if you wanted to have a Facebook Container and a Twitter Container, the Facebook Container would only know to block non-Facebook links-- it would have knowledge of other containers.

pjvds commented 3 years ago

@markstos awesome! That's all I need to be honest. Thanks for sharing this 🙌🏻

markstos commented 3 years ago

I've submitted some PRs to qutebrowser-profile this weekend. Assuming it gets merged, it will be a more robust option for multiple profiles. The new feautres include:

This kind of profile management is different than the "Firefox Containers" concept. Firefox Containers can automatically assign URLs to different containeres. With qutebrowser-profile, it's up to you to open and use the correct profile.

Fully separate profiles may be exactly what you want if for example you have both personal and work Google accounts are tired of problems switching back and forth between them in the same profile.

Here's a PR which contains all the recent updates. Feedback is welcome through that issue:

https://github.com/jtyers/qutebrowser-profile/pull/12

The-Compiler commented 3 years ago

@markstos also made a nice Reddit post comparing the existing solutions to this, and how they relate to what's proposed in this issue: Comparing qpm and qutebrowser-profile as Qutebrowser profile managers : qutebrowser

I think the first step towards a solution for this would be to refactor how we initialize profiles, so that we can easily create (and dispose of) profiles on-the-fly. I've done some work on that in #5936 and opened #5935 with some ideas on how to continue.

I'm also raising the priority of this issue, as I think at least basic support (opening a new window with another storage profile, similar to how private browsing works) is totally possible and is something I'd really like to see.

markstos commented 3 years ago

I regularly have 4 different profiles running and also have near-daily out-of-memory problems on a laptop with 16GB of RAM. When I killall qutebrowser, memory recovers to less than 2GB of usage.

So while I like the simplicity and isolation of using separate browser profiles, it seems there is a memory penalty to pay with some duplicated browser code loaded 4x. If a "Firefox containers" type of solution could result in significant memory savings, that would be welcome!

fine2006 commented 3 years ago

I regularly have 4 different profiles running and also have near-daily out-of-memory problems on a laptop with 16GB of RAM. When I killall qutebrowser, memory recovers to less than 2GB of usage.

So while I like the simplicity and isolation of using separate browser profiles, it seems there is a memory penalty to pay with some duplicated browser code loaded 4x. If a "Firefox containers" type of solution could result in significant memory savings, that would be welcome!

It seems like qutebrowser has some memory issues, that creep up over time. Even though I have never done a multiprofile setup, and run <10 tabs in 1 window only, if I let it stay overnight, it will spike in memory significantly until I killall qutebrowser after which it gets back to conservative numbers.

The-Compiler commented 3 years ago

@fine2006 See #1476, this is entirely unrelated to this issue.

fine2006 commented 3 years ago

Yea I forgot to link it, but I was speculating whether the problem came from that issue 😅

The-Compiler commented 2 years ago

@crocket See #2314 - after all, a new container will be in a new window. You can also already have a different --basedir for an entirely separate qutebrowser instance with a different config and storage.

xificurC commented 2 years ago

I'm not sure I understand the current state of affairs, so let me try to summarize:

So IIUC users would be happiest if qb could run multiple profiles in 1 process. Having the window limitation might be problematic to some users, but not for the majority (guessing!). But this is not yet implemented. Is this accurate? Is there an ETA on when this feature might land?

The-Compiler commented 2 years ago

I'm not sure I understand the current state of affairs, so let me try to summarize:

  • qutebrowser-profile allows starting multiple qutebrowser processes sharing a common config but otherwise being separated

Right.

  • running multiple instances of a browser can cause memory issues (this is true of any browser, not just qb)

Yes, and potentially other more minor issues because those two instances don't know of each other - say, e.g., :tab-select won't show tabs across all instances.

  • @The-Compiler would like to add support for opening a new window with a new profile. This profile could be a long-lived or ephemeral one. There is no support for this as of yet.

Right. Similarly to how we can open a window with a private profile, it would be great to be able to open a window with another named profile.

So IIUC users would be happiest if qb could run multiple profiles in 1 process. Having the window limitation might be problematic to some users, but not for the majority (guessing!). But this is not yet implemented. Is this accurate? Is there an ETA on when this feature might land?

No ETA I'm afraid. It's a feature I'd like to see (also e.g. having multiple private profiles rather than just "default"/"private"), but there are a lot of other things on my plate.

raj-magesh commented 2 years ago

I think Firefox's model of per-tab containers + making all daughter tabs belong to the same container is optimal. With colored tab indicators for each container and maybe integration with tree-style tabs, it would be perfect.

I use Temporary Containers on Firefox so every tab is isolated (except those assigned to specific containers, which allow persistent cookies, etc.)

I went through issue #2327 and am not sure exactly what the difficulty with per-tab containers is. Is it that session info can't be stored correctly? Would it be difficult to avoid saving private/temporary container information? I think per-window containers aren't flexible enough because having multiple browser windows open seems suboptimal (screen space, etc.)

elshize commented 2 years ago

I do think that the fact that it works within one window makes the container tabs on Firefox great. And the way you can forget about it once you set it up -- it will just open certain websites in correct containers. Container-per-window approach can get very annoying when you want to have websites from several containers open at the same time. That said, I'd welcome the ability to do this per window as well. But I do agree that the Firefox model is better; no idea, however, how much more complicated it is to implement.

The-Compiler commented 2 years ago

Switching the profile of an already open tab isn't going to be possible. Having this as a per-tab thing instead of per-window would be possible, but an initial implementation would probably be per-window, as private windows are. I still think it's a bit more challenging e.g. UI wise to do this tab-wise and there will likely be some open questions, but I agree it's probably worthwhile to have.

elshize commented 2 years ago

Switching the profile of an already open tab isn't going to be possible

Should be doable to add an option that would enforce opening in a new tab if the URL is detected to be from another container.

Anyway, it sounds reasonable to me to start with a per-window implementation. I can see how per-tab requires some careful UI consideration.

raj-magesh commented 2 years ago

Switching the profile of an already open tab isn't going to be possible.

I don't think it's possible in Firefox either (as far as I know), and I don't think it's necessary: if I need the tab in another container, I can yank and paste it.

Having this as a per-tab thing instead of per-window would be possible, but an initial implementation would probably be per-window, as private windows are. I still think it's a bit more challenging e.g. UI wise to do this tab-wise and there will likely be some open questions, but I agree it's probably worthwhile to have.

Awesome, looking forward to it at some point in the future! :D

aliceinwire commented 1 year ago

This is the only feature keeping me from switching to qutebrowser

The-Compiler commented 1 year ago

@aliceinwire please consider leaving a thumbs-up instead of a comment for things like this.

The-Compiler commented 1 year ago

FWIW, @s-praveen-kumar has written an userscript to manage different basedirs in a container-like way - see #7325.

simonhughxyz commented 5 months ago

Is there any news on this? Containers are a feature I could really use.

The-Compiler commented 5 months ago

Nope, otherwise it'd be here in this issue.

markstos commented 5 months ago

The external tool qutebrowser-profile was re-written from Bash to Python, resolving several issues with it. It could be tested as an alternative to a native solution:

https://github.com/jtyers/qutebrowser-profile

I used an old, patched Bash version of it to have separate work and personal profiles of Qutebrowser.

simonhughxyz commented 5 months ago

Nope, otherwise it'd be here in this issue.

Fair enough. Is there anyway I can help?

The-Compiler commented 5 months ago

Not off-hand I suppose. I believe we have various places that currently assume that there are only two profiles, and there are various unsolved questions (if/where to store data, when to clean things up, how the UI could look like, etc.). Can't say much more without taking a closer look myself, which hasn't happened so far.

simonhughxyz commented 5 months ago

Just having a look at the code myself to see if I can help in some way. Am I on the right track by looking at QWebEngineProfile?

I'm guessing that this is what keeps track of profile data? My understanding from reading this (https://qthub.com/static/doc/qt5/qtwebengine/qtwebengine-webenginewidgets-simplebrowser-example.html) is that you can have different profiles per tab.

simonhughxyz commented 5 months ago

Just having a look at the code myself to see if I can help in some way. Am I on the right track by looking at QWebEngineProfile?

I'm guessing that this is what keeps track of profile data? My understanding from reading this (https://qthub.com/static/doc/qt5/qtwebengine/qtwebengine-webenginewidgets-simplebrowser-example.html) is that you can have different profiles per tab.

I just realised that's QT5 and we are on QT6, but I assume that its a similar API.

The-Compiler commented 5 months ago

Yup! The first step towards this would probably be to refactor qutebrowser/browser/webengine/webenginesettings.py so that it doesn't assume just a global default_profile and private_profile. I just noticed that we have separate issues (and a past PR) for this: