New issue
Advanced search Search tips

Issue 703299 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

RenderProcessHost::GetActiveViewCount() is either broken or misnamed

Project Member Reported by a...@chromium.org, Mar 20 2017

Issue description

RenderProcessHost::GetActiveViewCount() says:

  // Returns the current number of active views in this process.  Excludes
  // any RenderViewHosts that are swapped out.
  size_t GetActiveViewCount();

The implementation, though, does nothing of the sort:

  size_t RenderProcessHost::GetActiveViewCount() {
    size_t num_active_views = 0;
    std::unique_ptr<RenderWidgetHostIterator> widgets(
        RenderWidgetHost::GetRenderWidgetHosts());
    while (RenderWidgetHost* widget = widgets->GetNextHost()) {
      // Count only RenderWidgetHosts in this process.
      if (widget->GetProcess()->GetID() == GetID())
        num_active_views++;
    }
    return num_active_views;
  }

What relies on GetActiveViewCount()? Three things.

1. RenderFrameHostImpl::AllowBindings() uses it to rule out the use of a given process for getting WebUI bindings. If a process already has more than one "view" then it doesn't qualify. The fact that it's really checking for more than one widget means that it's stricter than it intends to be, so this isn't a problem.

2. RenderProcessHostImpl::OnShutdownRequest() says:
  // Don't shut down if there are active RenderViews
which is untrue. Having *any* widgets will prevent shutdown here, rather than only active views.

3. RenderProcessHost::FastShutdownForPageCount(size_t count). The parameter is the number of pages. FastShutdownForPageCount() compares the page count to the number of "views". If they are the same, the RPHI thinks, "oh, the page count matches the views, so that's the entirety of what I'm hosting, so sure!" Because GetActiveViewCount() really returns widget counts, fast shutdown is not even tried in circumstances that it should.

===

What's the history here?

http://crrev.com/17941005 (r210055) changed things so that only swapped in widgets were returned from RenderWidgetHost::GetRenderWidgetHosts(). That was the last recent major change to GetActiveViewCount(), but it used to return widgets even before that. Let's dig more.

http://crrev.com/10533139 (r142197) introduced GetActiveViewCount(). From what I can tell, it's always counted widgets rather than views. In fact, if we look at http://crrev.com/16431010 (which added the call to GetActiveViewCount() to FastShutdownForPageCount(), you'll see that FastShutdownForPageCount() *also* used to look at the widget count.

===

So is this just a naming issue? Urgh.
 

Comment 1 by a...@chromium.org, Mar 24 2017

Status: Available (was: Started)

Comment 2 by a...@chromium.org, Mar 24 2017

Summary: RenderProcessHost::GetActiveViewCount() is either broken or misnamed (was: RenderProcessHost::GetActiveViewCount() is broken)
Project Member

Comment 3 by sheriffbot@chromium.org, Mar 28 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Assigned (was: Untriaged)
This bug has an owner, thus, it's been triaged. Changing status to "assigned".

Sign in to add a comment