Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Issue 1777233002: Top document isolation mode prototype (Closed)

Created:
4 years, 9 months ago by Xiaocheng
Modified:
4 years, 8 months ago
CC:
ajwong+watch_chromium.org, asvitkine+watch_chromium.org, chromium-reviews, creis+watch_chromium.org, darin-cc_chromium.org, jam, loading-reviews_chromium.org, nasko+codewatch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Top document isolation mode prototype Based on hanxi's patch (crrev.com/1348203005) with modification. nick's patch (crrev.com/1797363002) provides the same functionality in a cleaner way. BUG=594217 CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_site_isolation

Patch Set 1 #

Patch Set 2 : Doghouse SiteInstance, with bugs #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+69 lines, -2 lines) Patch
M chrome/app/generated_resources.grd View 1 1 chunk +11 lines, -0 lines 0 comments Download
M chrome/browser/about_flags.cc View 1 1 chunk +5 lines, -0 lines 0 comments Download
M content/browser/browsing_instance.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M content/browser/browsing_instance.cc View 1 1 chunk +22 lines, -0 lines 1 comment Download
M content/browser/site_instance_impl.h View 1 3 chunks +6 lines, -0 lines 0 comments Download
M content/browser/site_instance_impl.cc View 1 2 chunks +10 lines, -1 line 0 comments Download
M content/common/site_isolation_policy.cc View 1 2 chunks +5 lines, -1 line 0 comments Download
M content/public/browser/site_instance.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M content/public/common/content_switches.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M content/public/common/content_switches.cc View 1 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (8 generated)
Xiaocheng
PTAL. This is essentially the doghouse prototype we are using, with all debug info printing ...
4 years, 9 months ago (2016-03-10 11:01:12 UTC) #4
ncarter (slow)
Two main challenges I see in how to clean this up: (1) How to modify ...
4 years, 9 months ago (2016-03-11 00:31:28 UTC) #8
Xiaocheng
On 2016/03/11 at 00:31:28, nick wrote: > Two main challenges I see in how to ...
4 years, 9 months ago (2016-03-11 02:06:27 UTC) #9
ncarter (slow)
On 2016/03/11 02:06:27, Xiaocheng wrote: > On 2016/03/11 at 00:31:28, nick wrote: > > Two ...
4 years, 9 months ago (2016-03-11 17:47:21 UTC) #10
Xiaocheng
On 2016/03/11 at 17:47:21, nick wrote: > On 2016/03/11 02:06:27, Xiaocheng wrote: > > On ...
4 years, 9 months ago (2016-03-14 09:30:53 UTC) #12
ncarter (slow)
https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsing_instance.cc File content/browser/browsing_instance.cc (right): https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsing_instance.cc#newcode57 content/browser/browsing_instance.cc:57: instance->SetForDoghouse(use_doghouse); I think this choice (of which SiteInstance becomes ...
4 years, 9 months ago (2016-03-14 17:42:24 UTC) #13
Xiaocheng
On 2016/03/14 at 17:42:24, nick wrote: > https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsing_instance.cc > File content/browser/browsing_instance.cc (right): > > https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsing_instance.cc#newcode57 ...
4 years, 9 months ago (2016-03-15 08:10:12 UTC) #14
ncarter (slow)
4 years, 9 months ago (2016-03-16 19:34:55 UTC) #15
On 2016/03/15 08:10:12, Xiaocheng wrote:
> On 2016/03/14 at 17:42:24, nick wrote:
> >
>
https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsin...
> > File content/browser/browsing_instance.cc (right):
> > 
> >
>
https://codereview.chromium.org/1777233002/diff/20001/content/browser/browsin...
> > content/browser/browsing_instance.cc:57:
> instance->SetForDoghouse(use_doghouse);
> > I think this choice (of which SiteInstance becomes the doghouse) needs to
> somehow be aware of main frame / subframe state, which simply isn't available
at
> this level.
> > 
> > My expectation is that the first SiteInstance we create will be for the main
> frame, which we want to be non-doghouse process.
> 
> With more testing, I found out that this is not always the case. When opening
a
> new tab, the first SiteInstance is created for chrome-search://remote-ntp/. If
I
> navigate to another site, in some cases (which I haven't figured out exactly)
> the navigation is done without creating a new BrowsingInstance, and hence, the
> SiteInstance created for the main frame is not first created SiteInstance.
> 
> Of course we can do something like ignoring internal protocols (like
> chrome-search://) when deciding if a SiteInstance should be for doghouse. It
> looks like quite a dirty hack, though. A cleaner approach should be, as you
> said, looking at the frame tree.

I think the right strategy here is for the internal URLs ought to be registered
as ProcessPerSite, and for content to enforce a policy of 'keep ProcessPerSite
URLs out of the doghouse'.

For the New Tab Page, to prevent the iframes from being put in the 3rd party
process, I think we just need to do a bit more work, to make it so that
ChromeContentBrowserClient::ShouldUseProcessPerSite() returns true for the
iframe URLs (e.g. chrome-search://most-visited/ ). We can either keep the
mostvisited iframes in the NTP process, or we can put them in a second singleton
process.

> > The crashes you see may be process kills due to the LockToOrigin checks.
> Basically, you cannot have UseDedicatedProcessesForAllSites() return true and
> then also put two different sites in the same renderer process: the process
will
> be locked only to the first origin, and we will kill the renderer when the
> second site tries to e.g. read document.cookie.
> 
> Thanks for your comments -- it is indeed the cause of the crash. It no longer
> crashes after adding "if (IsForDoghouse()) return" in
> SiteInstanceImpl::LockToOrigin.
> 
> > The solution is to not have UseDedicatedProcessesForAllSites() return true
in
> doghouse mode. Ultimately doghouse is going to be a fourth site isolation mode
> (after --site-per-process, --isolate-extensions, and
> --isolate-sites-for-testing). Getting this mode implemented right seems like
> something that will require a pretty deep knowledge of the process model, so
I'm
> happy to take it on -- I actually started hacking on it on Friday. I am
> optimistic that I can have a patch up today.
> 
> A probably more complicated issue is what we should do when navigating from
> doghouse (say, clicking a link in an ad which opens a new tab)? The ad should
be
> in the doghouse, while the new tab should not. However, both tabs are in the
> same BrowsingInstance, which means that the ad and the new tab are using the
> same SiteInstance, which in turn means the new tab has to be in the doghouse.

Some top-level navigations will have to commit into the 3rd party process; this
is unavoidable. However, each subsequent navigation might give us an opportunity
to break free of the 3rd party process. I think the behavior we want is
something like "Top-level navigations should switch away from the 3rd party
process whenever possible". Historically we don't switch processes for normal
cross-site navigations, unless required for security reasons, because it it's
considered more efficient to avoid the process startup cost. But I expect that
cost is worth paying, if the alternative is paying a performance penalty by
staying in the 3rd party process.

We'll need code for this, and we'll need to test back/forward cases as well,
since the SiteInstance decisions we make are actually cached in the navigation
entries, I expect some tricky cases there.

> I'm wondering if there's any solution without altering the current model of
> SiteInstance and BrowsingInstance. Otherwise, maybe we need to redesign
> SiteInstance to allow multiple SiteInstances of the same site in the same
> BrowsingInstance.

It sounds like we're thinking about the same things.

I hope to avoid having multiple SiteInstances for the same site within a
BrowsingInstance, because that means allowing same-site frames to exist which
can postmessage each other, but not script each other, which is not how the
platform is supposed to work. I hope that we can solve this simply, by switching
BrowsingInstances; if that doesn't work in practice, we can talk about
approaches that involve architectural changes to the
SiteInstance/BrowsingInstance model.

Powered by Google App Engine
This is Rietveld 408576698