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

Issue 166533002: [wip] Introduce SiteInstanceKeepAlive.

Created:
6 years, 10 months ago by sadrul
Modified:
6 years, 10 months ago
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam, creis+watch_chromium.org, ajwong+watch_chromium.org, nasko
Visibility:
Public.

Description

gesture-nav: Add mechanism to fix taking screenshot after cross-process navigation. The screenshot capture code needs a SiteInstance (and its corresponding RenderProcessHost) to stay alive for long enough for the capture to succeed. So increment the active-view count on the SiteInstanceImpl and the pending view count on its RenderProcessHost when taking the screenshot, and reduce the counts after the taking the screenshot is complete. BUG=340682

Patch Set 1 #

Patch Set 2 : . #

Patch Set 3 : . #

Total comments: 5

Patch Set 4 : . #

Patch Set 5 : . #

Total comments: 15

Patch Set 6 : . #

Patch Set 7 : . #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+151 lines, -43 lines) Patch
M content/browser/frame_host/navigation_controller_impl_unittest.cc View 1 2 3 4 5 1 chunk +1 line, -1 line 0 comments Download
M content/browser/frame_host/navigation_entry_screenshot_manager.h View 1 2 3 4 5 4 chunks +14 lines, -1 line 0 comments Download
M content/browser/frame_host/navigation_entry_screenshot_manager.cc View 1 2 3 4 5 6 7 chunks +62 lines, -8 lines 0 comments Download
M content/browser/frame_host/render_frame_host_manager.h View 1 2 3 4 5 6 2 chunks +5 lines, -5 lines 0 comments Download
M content/browser/frame_host/render_frame_host_manager.cc View 1 2 3 4 5 6 2 chunks +25 lines, -28 lines 1 comment Download
M content/browser/web_contents/web_contents_view_aura_browsertest.cc View 1 2 3 4 5 6 3 chunks +44 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
sadrul
Hi Charlie. What do you think of this approach to fix taking screenshot for cross-process/cross-site ...
6 years, 10 months ago (2014-02-14 13:20:51 UTC) #1
mfomitchev
https://codereview.chromium.org/166533002/diff/100001/content/browser/frame_host/navigation_entry_screenshot_manager.cc File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right): https://codereview.chromium.org/166533002/diff/100001/content/browser/frame_host/navigation_entry_screenshot_manager.cc#newcode140 content/browser/frame_host/navigation_entry_screenshot_manager.cc:140: scoped_ptr<SiteInstanceKeepAlive> keep_alive( Why not just keep_alive = site_instance->AcquireKeepAlive()? AcquireKeepAlive() ...
6 years, 10 months ago (2014-02-14 16:21:35 UTC) #2
Charlie Reis
Sorry for the delayed reply-- I got hit with a stable blocker bug today. I ...
6 years, 10 months ago (2014-02-15 01:57:46 UTC) #3
mfomitchev
Hi Charlie, We had some offline discussions about this. One important point is that I ...
6 years, 10 months ago (2014-02-19 23:24:04 UTC) #4
Charlie Reis
On 2014/02/19 23:24:04, mfomitchev wrote: > Hi Charlie, > > We had some offline discussions ...
6 years, 10 months ago (2014-02-20 02:05:25 UTC) #5
sadrul
On 2014/02/20 02:05:25, Charlie Reis wrote: > On 2014/02/19 23:24:04, mfomitchev wrote: > > Hi ...
6 years, 10 months ago (2014-02-20 05:13:20 UTC) #6
sadrul
https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right): https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc#newcode92 content/browser/frame_host/navigation_entry_screenshot_manager.cc:92: instance_->decrement_active_view_count(); Do we need to do anything here to ...
6 years, 10 months ago (2014-02-20 05:13:30 UTC) #7
Charlie Reis
https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right): https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc#newcode79 content/browser/frame_host/navigation_entry_screenshot_manager.cc:79: // A temporary solution to keep a RenderViewHost and ...
6 years, 10 months ago (2014-02-20 19:01:52 UTC) #8
mfomitchev
https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right): https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc#newcode200 content/browser/frame_host/navigation_entry_screenshot_manager.cc:200: OnScreenshotSet(entry); We should get rid of this and just ...
6 years, 10 months ago (2014-02-20 19:15:47 UTC) #9
awong
https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right): https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_host/navigation_entry_screenshot_manager.cc#newcode169 content/browser/frame_host/navigation_entry_screenshot_manager.cc:169: base::Passed(&keep_alive))); On 2014/02/20 19:01:53, Charlie Reis wrote: > Albert, ...
6 years, 10 months ago (2014-02-20 22:44:31 UTC) #10
sadrul
6 years, 10 months ago (2014-02-21 03:51:16 UTC) #11
https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
File content/browser/frame_host/navigation_entry_screenshot_manager.cc (right):

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:79: // A
temporary solution to keep a RenderViewHost and SiteInstanceImpl live
On 2014/02/20 19:01:53, Charlie Reis wrote:
> Please add a TODO saying when this can be removed (when RenderFrameProxy
> replaces swappedout://).

Done (is there a crbug I can reference from the TODO?)

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:92:
instance_->decrement_active_view_count();
On 2014/02/20 19:01:53, Charlie Reis wrote:
> On 2014/02/20 05:13:31, sadrul wrote:
> > Do we need to do anything here to make sure the
SiteInstance/RenderProcessHost
> > gets destroyed if a previous attempt to destroy them was avoided because of
> this
> > keep-alive object?
> 
> Those methods don't do anything on their own, so yes.  I would recommend
adding
> a test for this, since this is very subtle behavior.

I have exposed RenderFrameHostManager::ShutdownRenderFrameHostsInSiteInstance()
as a public static function, and called it from here if
SiteInstanceImpl::active_view_count() becomes zero after dcrementing it here. I
believe this makes sure the SiteInstanceImpl is destroyed if it needs to be.

Now, I am also depending on this to clean up the RenderProcessHosts as needed. I
added some code to a browser-test
(WebContentsViewAuraTest.ScreenshotForSwappedOutRenderViews) that depends on
this, and it does seem to work OK. But is that always expected to cleanup
RenderProcessHosts like this? If not, should we do something more explicit (like
call into RenderProcessHostImpl::OnShutdownRequest(), or something less ugly)?

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:166:
base::Bind(&NavigationEntryScreenshotManager::OnScreenshotTaken,
On 2014/02/20 19:01:53, Charlie Reis wrote:
> What happens if we never make it to OnScreenshotTaken?  Is that possible? 
Will
> the process ever go away, or is it stuck as a zombie in that case?

CopyFromBackingStore callback is guaranteed to be called back. The possible
exception is during browser shutdown. So there's no risk of having zombies.

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:169:
base::Passed(&keep_alive)));
On 2014/02/20 19:01:53, Charlie Reis wrote:
> Albert, can I get your eyes on this?

I have changed the way the keep-alive object is sent to the callback.

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:200:
OnScreenshotSet(entry);
On 2014/02/20 19:15:48, mfomitchev wrote:
> We should get rid of this and just have ClearScreenshot(entry) to fix the unit
> test

Done.

https://codereview.chromium.org/166533002/diff/300001/content/browser/frame_h...
content/browser/frame_host/navigation_entry_screenshot_manager.cc:253: if
(entry->screenshot().get())
On 2014/02/20 19:15:48, mfomitchev wrote:
> I think this check is unnecessary if we make the fix in OnScreenshotTaken() -
if
> OnScreenshotSet() is called, the screenshot should be non-null

Done.

https://codereview.chromium.org/166533002/diff/540001/content/browser/frame_h...
File content/browser/frame_host/render_frame_host_manager.cc (left):

https://codereview.chromium.org/166533002/diff/540001/content/browser/frame_h...
content/browser/frame_host/render_frame_host_manager.cc:1173:
ClearSwappedOutRFHsInSiteInstance(site_instance_id, frame_tree_node_);
This line is removed from the static version. From reading the code below, it
looks like this will be taken care of from inside the loop. But I don't know
this for sure. Can you confirm? (is there something I can look at to verify for
myself)?

Powered by Google App Engine
This is Rietveld 408576698