New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 668690 link

Starred by 4 users

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature

Blocking:
issue 699559
issue 715130
issue 724191
issue 810506
issue 738387



Sign in to add a comment

Throttle occluded tabs the same way as background tabs

Project Member Reported by skyos...@chromium.org, Nov 25 2016

Issue description

We should throttle foreground tabs in windows that are completely occluded the same way as we throttle backgrounded tabs. In both cases the user cannot directly observe the web contents (module audio playback), so throttling could be used to save power.
 
Cc: keishi@chromium.org
Project Member

Comment 2 by sheriffbot@chromium.org, Nov 27 2017

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. If you change it back, also remove the "Hotlist-Recharge-Cold" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Owner: fdoray@chromium.org
fdoray@ was working on this, I believe.
Status: Assigned (was: Untriaged)

Comment 5 by fdoray@chromium.org, Nov 29 2017

Cc: fdoray@chromium.org skuhne@chromium.org elijahtaylor@chromium.org bccheng@chromium.org vovoy@chromium.org chrisha@chromium.org xiy...@chromium.org
 Issue 788827  has been merged into this issue.

Comment 6 by fdoray@chromium.org, Nov 29 2017

Yes, I'm actively working on this.

I created aura::WindowOcclusionTracker to track the occlusion state of tabs. I'm now working on using signals from aura::WindowOcclusionTracker to throttle execution and disable rendering in occluded tabs.

For the record, message from yusukes@:
Is there a plan to limit CPU usage of foreground Chrome renderer process(es) with either RenderProcessHostImpl::UpdateProcessPriority(), ChildProcessLauncher::SetProcessPriority(), or base::SetProcessBackgrounded() when their Chrome browser window(s) are completely covered by another window? This seems like a good thing to make sure a maximized/fullscreen ARC++ window can use 100% of CPU time. 


Cc: yusukes@chromium.org
Blocking: 738387
Project Member

Comment 9 by bugdroid1@chromium.org, Dec 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5ff27a43b04dfc57bc6d47f8f4b653a93115a7ab

commit 5ff27a43b04dfc57bc6d47f8f4b653a93115a7ab
Author: Francois Doray <fdoray@chromium.org>
Date: Mon Dec 04 19:29:57 2017

Support changing a window with tracked occlusion while it's added to a root.

Previously, a DCHECK failure occurred if a WindowObserver or a
LayoutManager changed a tracked window after Window::AddChild() added
it to a root but before WindowOcclusionTracker::OnWindowAddedToRootWindow
was notified. With this CL, the DCHECK is replaced with an early return.
We rely on WindowOcclusionTracker::OnWindowAddedToRootWindow to
mark the new root as dirty shortly after the early return.

Bug: 668690
Change-Id: I0030869c01bb2955bcd8c31b7e5212cb404dc794
Reviewed-on: https://chromium-review.googlesource.com/804120
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521405}
[modify] https://crrev.com/5ff27a43b04dfc57bc6d47f8f4b653a93115a7ab/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/5ff27a43b04dfc57bc6d47f8f4b653a93115a7ab/ui/aura/window_occlusion_tracker_unittest.cc

Project Member

Comment 10 by bugdroid1@chromium.org, Dec 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8678167cbb906241651619733ba666c505f053c0

commit 8678167cbb906241651619733ba666c505f053c0
Author: Francois Doray <fdoray@chromium.org>
Date: Mon Dec 04 19:53:50 2017

Support deleting a window with tracked occlusion from LayerAnimationObserver::OnLayerAnimationEnded.

Previously, if a window with tracked occlusion was deleted from
LayerAnimationObserver::OnLayerAnimationEnded, an invalid memory
access occurred in WindowOcclusionTracker::CleanupAnimatedWindows
(because the window was deleted before being removed from
|animated_windows_|).

This CL fixes this problem by removing the Window* from
|animated_windows_| in WindowOcclusionTracker::OnWindowDestroyed.

Bug: 668690
Change-Id: I77749c79d72d7cebc3a77647552605c8abec3abb
Reviewed-on: https://chromium-review.googlesource.com/806356
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521420}
[modify] https://crrev.com/8678167cbb906241651619733ba666c505f053c0/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/8678167cbb906241651619733ba666c505f053c0/ui/aura/window_occlusion_tracker_unittest.cc

Project Member

Comment 11 by bugdroid1@chromium.org, Dec 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7e7bd7c072f90c7826dba173543856f2c50fdfaf

commit 7e7bd7c072f90c7826dba173543856f2c50fdfaf
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Dec 05 19:39:51 2017

Add setPretendIsOccluded to CocoaTestHelperWindow.

This method simulates occlusion of the CocoaTestHelperWindow
(return value of occlusionState and posting
NSWindowDidChangeOcclusionStateNotification).

Bug: 668690
Change-Id: Ie6acab5d9ec2032dac92e8941b754fb42d45f7db
Reviewed-on: https://chromium-review.googlesource.com/802134
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521787}
[modify] https://crrev.com/7e7bd7c072f90c7826dba173543856f2c50fdfaf/ui/gfx/test/ui_cocoa_test_helper.h
[modify] https://crrev.com/7e7bd7c072f90c7826dba173543856f2c50fdfaf/ui/gfx/test/ui_cocoa_test_helper.mm

Project Member

Comment 12 by bugdroid1@chromium.org, Dec 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6

commit 0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6
Author: Francois Doray <fdoray@chromium.org>
Date: Mon Dec 11 18:11:18 2017

Add content::RenderWidgetHostViewBase::GetRenderWidgetHostImpl().

This method avoids casts from RenderWidgetHost to
RenderWidgetHostImpl.

Bug: 668690
Change-Id: I9618a61d9582e104b3041698d8368a8b14525d7f
Reviewed-on: https://chromium-review.googlesource.com/797010
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523137}
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/frame_host/cross_process_frame_connector.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/frame_host/interstitial_page_impl.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/input/mouse_wheel_phase_handler.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/input/touch_selection_controller_client_aura.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/input/touch_selection_controller_client_child_frame.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_input_event_router.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_android.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_android.h
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_aura.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_aura.h
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_base.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_base.h
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_child_frame.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_child_frame.h
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_event_handler.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_mac.h
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/renderer_host/render_widget_host_view_mac.mm
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/test/test_render_view_host.cc
[modify] https://crrev.com/0f5e2d79efe3481cfb1c47c3bb02b7645ff256c6/content/test/test_render_view_host.h

Project Member

Comment 13 by bugdroid1@chromium.org, Dec 12 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/54794b55e781258bde11a417eaa69f8c69c08671

commit 54794b55e781258bde11a417eaa69f8c69c08671
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Dec 12 18:24:36 2017

Use MockRenderWidgetHostDelegate in RenderWidgetHostViewMacTest::SetUp().

Instead of having multiple test cases performing the same initialization
of a MockRenderWidgetHostImpl with a MockRenderWidgetHostDelegate, do
this in SetUp().

Bug: 668690
Change-Id: I12a6cf7d60ea0edf56147ce8201aacabed56158d
Reviewed-on: https://chromium-review.googlesource.com/801539
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523484}
[modify] https://crrev.com/54794b55e781258bde11a417eaa69f8c69c08671/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Project Member

Comment 14 by bugdroid1@chromium.org, Dec 14 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6789a487e264cc7d02499ba965771746ea3d2655

commit 6789a487e264cc7d02499ba965771746ea3d2655
Author: Francois Doray <fdoray@chromium.org>
Date: Thu Dec 14 00:21:53 2017

Add content::MockRenderWidgetHostDelegate.

This new class avoids having separate mock definitions in
render_widget_host_view_(aura|mac)_unittest.(cc|mm).

Having a single mock definition will simplify writing
common tests for occlusion tracking in
RenderWidgetHostView(Aura|Mac).

Bug: 668690
Change-Id: I7d7c0c39bf266014374df0b307eecc2a9047820d
Reviewed-on: https://chromium-review.googlesource.com/797851
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523948}
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/frame_host/render_widget_host_view_guest_unittest.cc
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/renderer_host/cursor_manager_unittest.cc
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/renderer_host/render_widget_host_input_event_router_unittest.cc
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/renderer_host/render_widget_host_view_child_frame_unittest.cc
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
[modify] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/test/BUILD.gn
[delete] https://crrev.com/db7ca8c4009844b26cf03a20a1c93a15519d4ea3/content/test/dummy_render_widget_host_delegate.h
[add] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/test/mock_render_widget_host_delegate.cc
[add] https://crrev.com/6789a487e264cc7d02499ba965771746ea3d2655/content/test/mock_render_widget_host_delegate.h

Project Member

Comment 15 by bugdroid1@chromium.org, Dec 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0402541097268de100e753152d6698e25fed586f

commit 0402541097268de100e753152d6698e25fed586f
Author: Francois Doray <fdoray@chromium.org>
Date: Mon Dec 18 21:44:19 2017

Stop observing animations on window without tracked occlusion when it's removed from its root.

WindowOcclusionTracker already removes itself from the
WindowObserver list of a Window without tracked occlusion when it's
removed from its root. With this CL, it also removes itself from
the LayerAnimationObserver list of its LayerAnimator.

Bug: 668690
Change-Id: I667fe140383e8afe57933d1f3b1831c94d1a46f3
Reviewed-on: https://chromium-review.googlesource.com/822655
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524809}
[modify] https://crrev.com/0402541097268de100e753152d6698e25fed586f/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/0402541097268de100e753152d6698e25fed586f/ui/aura/window_occlusion_tracker_unittest.cc

François, could you let me know the current status of this bug? I'd especially like to know if  issue 788827  (ARC++ cpu usage issue) has already been fixed or not. Thanks.

Project Member

Comment 17 by bugdroid1@chromium.org, Jan 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ad2356e01c720eed788977faadbefee181a9ea69

commit ad2356e01c720eed788977faadbefee181a9ea69
Author: Francois Doray <fdoray@chromium.org>
Date: Wed Jan 17 18:52:17 2018

Fix visibility updates in WebContentsViewAura.

Previously, the visibility of a WebContents was set to "visible"
whenever one of its parent became visible. With this CL, all parents
must be visible for the WebContents to become visible.

Bug: 668690
Change-Id: I3b67d6ed6c2e2a1488969e14b03d8dfb47ccd566
Reviewed-on: https://chromium-review.googlesource.com/866992
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529828}
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/chrome/browser/sessions/session_restore_observer_unittest.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/chrome/browser/sessions/session_restore_stats_collector.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/chrome/browser/sessions/session_restore_stats_collector_unittest.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/chrome/browser/sessions/tab_loader_unittest.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/content/browser/web_contents/web_contents_view_aura.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/ad2356e01c720eed788977faadbefee181a9ea69/ui/views/controls/webview/webview_unittest.cc

yusukes@: 
I'm actively working on this. Unfortunately,  issue 788827  hasn't been fixed yet. It will be once these CLs have landed, plus an extra CL to send PageMsg_WasHidden to occluded tabs.
- https://chromium-review.googlesource.com/c/chromium/src/+/832828
- https://chromium-review.googlesource.com/c/chromium/src/+/861953
- https://chromium-review.googlesource.com/c/chromium/src/+/867511
- https://chromium-review.googlesource.com/c/chromium/src/+/867478
Project Member

Comment 19 by bugdroid1@chromium.org, Feb 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5ab60ca7a83ac37c212f598fe8948596f8990c10

commit 5ab60ca7a83ac37c212f598fe8948596f8990c10
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Feb 06 12:25:26 2018

Make an aura::Window with a non-occluded child non-occluded.

This is useful when we have a window hierarchy like this:
  WebContentsViewAura (x=0, y=0, w=10, h=10)
    RenderWidgetHostViewAura (x=0, y=0, w=10, h=10)
The WebContentsViewAura is covered by a child, but when comes
the time to determine the occlusion state of the WebContents,
we would like to get NOT_OCCLUDED.

Asking clients of the API to traverse the window tree themselves
to determine whether a window has a non-occluded child would be
error-prone, as occlusion states aren't updated atomically
(e.g. if Hide() is called on the RenderWidgetHostViewAura, its
occlusion state will be updated to OCCLUDED before the occlusion
state of the WebContentsViewAura is updated to NOT_OCCLUDED).

Bug: 668690
Change-Id: I3a2777be37ce697d7215396b6626bce6ff72416c
Reviewed-on: https://chromium-review.googlesource.com/832828
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534678}
[modify] https://crrev.com/5ab60ca7a83ac37c212f598fe8948596f8990c10/ui/aura/window.h
[modify] https://crrev.com/5ab60ca7a83ac37c212f598fe8948596f8990c10/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/5ab60ca7a83ac37c212f598fe8948596f8990c10/ui/aura/window_occlusion_tracker.h
[modify] https://crrev.com/5ab60ca7a83ac37c212f598fe8948596f8990c10/ui/aura/window_occlusion_tracker_unittest.cc

Blocking: 810506
Blocking: 724191
Blocking: 715130
Project Member

Comment 23 by bugdroid1@chromium.org, Feb 16 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a2f523dc9b60f1d5cd604986575d38a04af48beb

commit a2f523dc9b60f1d5cd604986575d38a04af48beb
Author: Francois Doray <fdoray@chromium.org>
Date: Fri Feb 16 15:54:30 2018

Support changing the window tree from aura::WindowDelegate::OnWindowOcclusionChanged.

Some code in Chrome needs to change the window tree in response
to a change of visibility for a WebContents (e.g. close zoom
bubble, create a new RenderWidgetHostViewAura). Because of that,
we need to allow changes to the window tree from
aura::WindowDelegate::OnWindowOcclusionChanged().

With this CL, aura::Window::SetOcclusionState() is not called
immediately when the occlusion of a tracked window is computed.
Instead, we compute occlusion for all tracked windows. Then,
we call aura::Window::SetOcclusionState() on all tracked
windows. Having separate phases ensures that the window tree is
not modified while occlusion is being computed. If a call to
aura::Window::SetOcclusionState() in the 2nd phase changes the
window tree in a way that could affect occlusion, we go back
to phase 1. There is a hard cap of 2 iterations, after which we
crash.

Bug: 668690,  813076 
Change-Id: I61e5cdbb605343a5b587aeb96effcbd8dc07de33
Reviewed-on: https://chromium-review.googlesource.com/861953
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537310}
[modify] https://crrev.com/a2f523dc9b60f1d5cd604986575d38a04af48beb/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/a2f523dc9b60f1d5cd604986575d38a04af48beb/ui/aura/window_occlusion_tracker.h
[modify] https://crrev.com/a2f523dc9b60f1d5cd604986575d38a04af48beb/ui/aura/window_occlusion_tracker_unittest.cc

Project Member

Comment 24 by bugdroid1@chromium.org, Feb 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d

commit fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d
Author: Francois Doray <fdoray@chromium.org>
Date: Sat Feb 17 04:17:09 2018

Expose occlusion in WebContents and WebContentsObserver.

This CL:
- Adds content::Visibility {VISIBLE, OCCLUDED, HIDDEN}.
- Replaces
   bool WebContents::IsVisible();
  with
   Visibility WebContents::GetVisibility();
- Replaces
   void WebContents::WasShown();
   void WebContents::WasHidden();
  with
   void WebContents::OnVisibilityChanged(Visibility);

FAQ:

- What is the meaning of VISIBLE, OCCLUDED or HIDDEN?
    https://chromium-review.googlesource.com/c/chromium/src/+/867511/17/content/public/browser/visibility.h

- What should I consider when reviewing an updated call site?
    Before, WasShown()/WasHidden() were called for these
    transitions:
      visible or occluded -> hidden
      hidden -> visible or occluded
    Now, OnVisibilityChanged() is called for each of these
    transitions:
      VISIBLE -> OCCLUDED
      OCCLUDED -> VISIBLE
      HIDDEN -> VISIBLE:
      HIDDEN -> OCCLUDED
      VISIBLE -> HIDDEN
      OCCLUDED -> HIDDEN

- Why a single OnVisibilityChanged observer method instead of
  WasShown/WasHidden/WasOccluded?
    Having a single method makes it clearer that visibility
    states are mutually exclusive.

- Why do we need an OCCLUDED state?
    We plan to use it for metrics recording and to reduce
    resource usage in occluded tabs. This is important to
    improve the experience of users that use many windows.
    https://groups.google.com/a/google.com/d/msg/chrome-desktop/3Qp1857tqw4/E8Qp-YgoDQAJ

Bug: 668690
Change-Id: I7a6aa905619f51f5d5463f583bdb4640d57aff00
Reviewed-on: https://chromium-review.googlesource.com/867511
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: Michael Giuffrida <michaelpg@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Reviewed-by: rajendrant <rajendrant@chromium.org>
Reviewed-by: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Carlos Knippschild <carlosk@chromium.org>
Reviewed-by: Kevin McNee <mcnee@chromium.org>
Reviewed-by: Mathieu Perreault <mathp@chromium.org>
Reviewed-by: Patti <patricialor@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Bryan McQuade <bmcquade@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537529}
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/android/oom_intervention/oom_intervention_tab_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/apps/guest_view/web_view_browsertest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/autofill/content_autofill_driver_browsertest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/data_use_measurement/data_use_web_contents_observer.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/data_use_measurement/data_use_web_contents_observer.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/engagement/site_engagement_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/engagement/site_engagement_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/engagement/site_engagement_helper_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/media/media_engagement_contents_observer_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/metrics/first_web_contents_profiler.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/metrics/oom/out_of_memory_reporter.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/metrics/tab_stats_data_store.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/metrics/tab_stats_tracker.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/notifications/notification_permission_context.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/offline_pages/recent_tab_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/offline_pages/recent_tab_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/offline_pages/recent_tab_helper_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/page_load_metrics/metrics_web_contents_observer.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/page_load_metrics/metrics_web_contents_observer_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/password_manager/account_chooser_dialog_android.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/password_manager/account_chooser_dialog_android.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/password_manager/auto_signin_first_run_dialog_android.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/password_manager/auto_signin_first_run_dialog_android.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/permissions/permission_request_manager.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/permissions/permission_request_manager.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/permissions/permission_request_manager_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/background_tab_navigation_throttle.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/resource_coordinator_web_contents_observer.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/resource_coordinator_web_contents_observer.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_activity_watcher.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_manager.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_manager_stats_collector.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_manager_web_contents_data.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/resource_coordinator/tab_manager_web_contents_data.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/autofill/save_card_bubble_controller_impl.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/autofill/save_card_bubble_controller_impl.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/popup_opener_tab_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/popup_opener_tab_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/popup_opener_tab_helper_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/popup_tracker.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/popup_tracker.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/blocked_content/tab_under_blocker_browsertest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/cocoa/constrained_window/constrained_window_mac_browsertest.mm
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/passwords/manage_passwords_ui_controller.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/passwords/manage_passwords_ui_controller.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/tab_contents/core_tab_helper.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/tab_contents/core_tab_helper.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/content_setting_bubble_contents.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/content_setting_bubble_contents.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/location_bar/zoom_bubble_view.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/page_info/page_info_bubble_view_base.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/chrome/browser/ui/views/page_info/page_info_bubble_view_base.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/components/autofill/content/browser/content_autofill_driver_factory.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/components/autofill/content/browser/content_autofill_driver_factory.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/components/web_modal/web_contents_modal_dialog_manager.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/components/web_modal/web_contents_modal_dialog_manager.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/components/web_modal/web_contents_modal_dialog_manager_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/android/dialog_overlay_impl.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/android/dialog_overlay_impl.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/android/web_contents_observer_proxy.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/android/web_contents_observer_proxy.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/browser_plugin/browser_plugin_guest.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/devtools/render_frame_devtools_agent_host.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/devtools/render_frame_devtools_agent_host.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/media/capture/web_contents_video_capture_device_browsertest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/media/media_web_contents_observer.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/media/media_web_contents_observer.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/public/browser/BUILD.gn
[add] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/public/browser/visibility.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/public/browser/web_contents.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/content/public/browser/web_contents_observer.h
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/extensions/browser/guest_view/web_view/web_view_apitest.cc
[modify] https://crrev.com/fe4a1775a29fa1918d74dbaf0c5310acb2ccd85d/ui/views/controls/webview/webview_unittest.cc

Project Member

Comment 25 by bugdroid1@chromium.org, Feb 20 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6276e797cd584cd69eb2a383e698a1e03f617c0d

commit 6276e797cd584cd69eb2a383e698a1e03f617c0d
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Feb 20 18:10:58 2018

Remove unwanted logging from web_contents_modal_dialog_manager.cc.

The log statements were added by error by
https://chromium-review.googlesource.com/c/chromium/src/+/867511

TBR=wittman@chromium.org

Bug: 668690
Change-Id: Iefaa5d6cf254762230d8dd4bf04b903689d36777
Reviewed-on: https://chromium-review.googlesource.com/926782
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537821}
[modify] https://crrev.com/6276e797cd584cd69eb2a383e698a1e03f617c0d/components/web_modal/web_contents_modal_dialog_manager.cc

Project Member

Comment 26 by bugdroid1@chromium.org, Feb 27 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cf6918de683c4260666b9a1bb782f7e3c4f04c4f

commit cf6918de683c4260666b9a1bb782f7e3c4f04c4f
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Feb 27 17:24:03 2018

Add aura::Window::OcclusionState:HIDDEN.

This CL adds an occlusion state to allow delegates to be notified when
a window goest from hidden <-> occluded.

Bug: 668690
Change-Id: I3b16a699ab5d8e6050332e5146007766b0c3949f
Reviewed-on: https://chromium-review.googlesource.com/927205
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539479}
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window.cc
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window.h
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window_delegate.h
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window_occlusion_tracker.h
[modify] https://crrev.com/cf6918de683c4260666b9a1bb782f7e3c4f04c4f/ui/aura/window_occlusion_tracker_unittest.cc

Project Member

Comment 27 by bugdroid1@chromium.org, Mar 1 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/63c0797380c87f558c2d06c00673d1abc044aba3

commit 63c0797380c87f558c2d06c00673d1abc044aba3
Author: Francois Doray <fdoray@chromium.org>
Date: Thu Mar 01 13:54:08 2018

Handle WebContents occlusion on aura.

With this CL, when a WebContents is occluded on aura:
- WebContents::GetVisibility returns OCCLUDED
- RenderWidgetHostImpl::WasHidden is called on all
  RenderWidgetHostImpls that belong to the WebContents.
  That allows:
  - Changing the priority of renderer processes to background.
  - Not rendering frames unnecessarily.

Bug: 668690
Change-Id: Ie1c86d271276576a6b5c7adfb11bd0e42d5d491e
Reviewed-on: https://chromium-review.googlesource.com/937820
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540149}
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/chrome/browser/engagement/site_engagement_helper_unittest.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_impl_unittest.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_aura.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_aura.h
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_aura_browsertest.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_mac.mm
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/browser/web_contents/web_contents_view_mac_unittest.mm
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/public/browser/render_widget_host_view.h
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/public/browser/web_contents.h
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/content/shell/browser/shell.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/ui/views/controls/native/native_view_host_aura.cc
[modify] https://crrev.com/63c0797380c87f558c2d06c00673d1abc044aba3/ui/views/controls/webview/webview_unittest.cc

Project Member

Comment 28 by bugdroid1@chromium.org, Mar 2 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/c7056ddb3e81ad2e9a1fdd8fe48c6b65d400153b

commit c7056ddb3e81ad2e9a1fdd8fe48c6b65d400153b
Author: Francois Doray <fdoray@chromium.org>
Date: Fri Mar 02 23:50:14 2018

Add histograms to track the time spent by tabs in each visibility state.

We will sum the values in each of the 3 histograms for a given time
interval to determine what percentage of the time is spent in each
visibility state. That will help us assess the importance of reducing
resource consumption in hidden and occluded tabs.

Bug: 668690
Change-Id: I18d3f5c93de105fda83ae6d362f4677ed86a5937
Reviewed-on: https://chromium-review.googlesource.com/946673
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sébastien Marchand <sebmarchand@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540686}
[modify] https://crrev.com/c7056ddb3e81ad2e9a1fdd8fe48c6b65d400153b/chrome/browser/resource_coordinator/tab_activity_watcher.cc
[modify] https://crrev.com/c7056ddb3e81ad2e9a1fdd8fe48c6b65d400153b/tools/metrics/histograms/histograms.xml

Project Member

Comment 29 by bugdroid1@chromium.org, Mar 3 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/04a802475fdedf795b626b2e9635e5a93644d376

commit 04a802475fdedf795b626b2e9635e5a93644d376
Author: Mitsuru Oshima <oshima@chromium.org>
Date: Sat Mar 03 03:06:15 2018

Revert "Handle WebContents occlusion on aura."

This reverts commit 63c0797380c87f558c2d06c00673d1abc044aba3.

Reason for revert: This is causing  crbug.com/818010  and  crbug.com/817957 .

Original change's description:
> Handle WebContents occlusion on aura.
> 
> With this CL, when a WebContents is occluded on aura:
> - WebContents::GetVisibility returns OCCLUDED
> - RenderWidgetHostImpl::WasHidden is called on all
>   RenderWidgetHostImpls that belong to the WebContents.
>   That allows:
>   - Changing the priority of renderer processes to background.
>   - Not rendering frames unnecessarily.
> 
> Bug: 668690
> Change-Id: Ie1c86d271276576a6b5c7adfb11bd0e42d5d491e
> Reviewed-on: https://chromium-review.googlesource.com/937820
> Reviewed-by: Peter Beverloo <peter@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Dominick Ng <dominickn@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#540149}

TBR=avi@chromium.org,sky@chromium.org,peter@chromium.org,fdoray@chromium.org,dominickn@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 668690
Change-Id: Id58705c66157cb18be220cc59b29a50fd3b14d95
Reviewed-on: https://chromium-review.googlesource.com/947802
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#540735}
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/chrome/browser/engagement/site_engagement_helper_unittest.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_impl_unittest.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_aura.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_aura.h
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_aura_browsertest.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_mac.mm
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/browser/web_contents/web_contents_view_mac_unittest.mm
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/public/browser/render_widget_host_view.h
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/public/browser/web_contents.h
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/content/shell/browser/shell.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/ui/views/controls/native/native_view_host_aura.cc
[modify] https://crrev.com/04a802475fdedf795b626b2e9635e5a93644d376/ui/views/controls/webview/webview_unittest.cc

Project Member

Comment 30 by bugdroid1@chromium.org, Mar 5 2018

Labels: merge-merged-3359
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dc07788392e6d168561f14a44c75e077d184471a

commit dc07788392e6d168561f14a44c75e077d184471a
Author: Xiaoqian Dai <xdai@chromium.org>
Date: Mon Mar 05 23:57:16 2018

[Merge to M66] Revert "Handle WebContents occlusion on aura."

This reverts commit 63c0797380c87f558c2d06c00673d1abc044aba3.

Reason for revert: This is causing  crbug.com/818010  and  crbug.com/817957 .

Original change's description:
> Handle WebContents occlusion on aura.
>
> With this CL, when a WebContents is occluded on aura:
> - WebContents::GetVisibility returns OCCLUDED
> - RenderWidgetHostImpl::WasHidden is called on all
>   RenderWidgetHostImpls that belong to the WebContents.
>   That allows:
>   - Changing the priority of renderer processes to background.
>   - Not rendering frames unnecessarily.
>
> Bug: 668690
> Change-Id: Ie1c86d271276576a6b5c7adfb11bd0e42d5d491e
> Reviewed-on: https://chromium-review.googlesource.com/937820
> Reviewed-by: Peter Beverloo <peter@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Dominick Ng <dominickn@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: François Doray <fdoray@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#540149}

TBR=avi@chromium.org,sky@chromium.org,peter@chromium.org,fdoray@chromium.org,dominickn@chromium.org


(cherry picked from commit 04a802475fdedf795b626b2e9635e5a93644d376)

Bug: 668690
Change-Id: Id58705c66157cb18be220cc59b29a50fd3b14d95
Reviewed-on: https://chromium-review.googlesource.com/947802
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#540735}
Reviewed-on: https://chromium-review.googlesource.com/950140
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/branch-heads/3359@{#23}
Cr-Branched-From: 66afc5e5d10127546cc4b98b9117aff588b5e66b-refs/heads/master@{#540276}
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/chrome/browser/engagement/site_engagement_helper_unittest.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_impl_unittest.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_aura.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_aura.h
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_aura_browsertest.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_mac.mm
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/browser/web_contents/web_contents_view_mac_unittest.mm
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/public/browser/render_widget_host_view.h
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/public/browser/web_contents.h
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/content/shell/browser/shell.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/ui/views/controls/native/native_view_host_aura.cc
[modify] https://crrev.com/dc07788392e6d168561f14a44c75e077d184471a/ui/views/controls/webview/webview_unittest.cc

Status: Started (was: Assigned)
(marking as started)
Before you land/enable this by default, could you please make sure that this doesn't break multi-profile as well as  crbug.com/818010 ? thanks!
Plus, please test overview and task switcher (alt-tab) as well because they're using mirrored view of the window to show the live content.
Project Member

Comment 34 by bugdroid1@chromium.org, Mar 20 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/71f63e241b81bcda8dab9d53478ba6d9ab94a83d

commit 71f63e241b81bcda8dab9d53478ba6d9ab94a83d
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Mar 20 14:48:36 2018

Set aura::Window transparency in SurfaceTreeHost::UpdateHostWindowBounds().

SurfaceTreeHost::UpdateHostWindowBounds() used to call
ui::Layer::SetFillsBoundsOpaquely() directly. With this CL, the method
is called through aura::Window::SetTransparent(). This is equivalent,
except that the |transparent_| bit of the aura::Window, on which
aura::WindowOcclusionTracker depends, is also updated.

This CL also adds a ScopedPauseOcclusionTracking instance to ensure
that occlusion isn't recomputed multiple times during a call to
SurfaceTreeHost::UpdateHostWindowBounds().

Bug: 668690
Change-Id: I4f6181d4e247f2a54d96569b3379964c9253246a
Reviewed-on: https://chromium-review.googlesource.com/970746
Reviewed-by: David Reveman <reveman@chromium.org>
Commit-Queue: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544362}
[modify] https://crrev.com/71f63e241b81bcda8dab9d53478ba6d9ab94a83d/components/exo/surface_tree_host.cc

Project Member

Comment 35 by bugdroid1@chromium.org, Mar 23 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4f44caa1b4678e6a149953c156b004f1becc4a20

commit 4f44caa1b4678e6a149953c156b004f1becc4a20
Author: Francois Doray <fdoray@chromium.org>
Date: Fri Mar 23 15:48:05 2018

Don't compute occlusion when window with hidden parent is hidden/shown.

A window with a hidden parent is not painted on the screen. Calling
Hide() or Show() on it can't immediately affect occlusion and
should therefore not cause occlusion states to be recomputed.

This optimization is useful for when we hide a WebContentsViewAura.
When we hide a WebContentsViewAura, Hide() is called on child
RenderWidgetHostViewAura. There is no reason to recompute occlusion
when that happens.

Bug: 668690
Change-Id: Id02c195aa5e74313fdc790e365c19337615fcf2b
Reviewed-on: https://chromium-review.googlesource.com/970848
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545462}
[modify] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/BUILD.gn
[add] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/test/window_occlusion_tracker_test_api.cc
[add] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/test/window_occlusion_tracker_test_api.h
[modify] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/window_occlusion_tracker.cc
[modify] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/window_occlusion_tracker.h
[modify] https://crrev.com/4f44caa1b4678e6a149953c156b004f1becc4a20/ui/aura/window_occlusion_tracker_unittest.cc

Project Member

Comment 36 by bugdroid1@chromium.org, Mar 27 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e616115a9b1dca27ffdf447c79b4413305c49bb4

commit e616115a9b1dca27ffdf447c79b4413305c49bb4
Author: Francois Doray <fdoray@chromium.org>
Date: Tue Mar 27 22:05:37 2018

Handle WebContents occlusion on aura (reland).

This CL is identical to
https://chromium-review.googlesource.com/c/chromium/src/+/937820, which
was reverted because it broke window resizer ( https://crbug.com/818010 ).
That issue was addressed in
https://chromium-review.googlesource.com/c/chromium/src/+/970746.
I also verified that this CL doesn't break Alt-Tab, overview mode,
multi-profile and testForegroundTab test ( https://crbug.com/817957 ,
100/100 runs pass now vs 12/100 runs without
https://chromium-review.googlesource.com/c/chromium/src/+/970746).

With this CL, when a WebContents is occluded on aura:
- WebContents::GetVisibility returns OCCLUDED
- RenderWidgetHostImpl::WasHidden is called on all
  RenderWidgetHostImpls that belong to the WebContents.
  That allows:
  - Changing the priority of renderer processes to background.
  - Not rendering frames unnecessarily.

TBR=dominickn@chromium.org,sky@chromium.org,avi@chromium.org,peter@chromium.org

Bug: 668690
Change-Id: I040b93738561c463654c50d6f42ce19c447c6693
Reviewed-on: https://chromium-review.googlesource.com/973682
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546286}
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/chrome/browser/engagement/site_engagement_helper_unittest.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/browser_plugin/browser_plugin_guest.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_impl_unittest.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_aura.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_aura.h
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_aura_browsertest.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_mac.mm
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/browser/web_contents/web_contents_view_mac_unittest.mm
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/public/browser/render_widget_host_view.h
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/public/browser/web_contents.h
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/content/shell/browser/shell.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/ui/views/controls/native/native_view_host_aura.cc
[modify] https://crrev.com/e616115a9b1dca27ffdf447c79b4413305c49bb4/ui/views/controls/webview/webview_unittest.cc

Project Member

Comment 37 by bugdroid1@chromium.org, Apr 6 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3f2afbd368796afa238f6950885d2c158cb197f3

commit 3f2afbd368796afa238f6950885d2c158cb197f3
Author: Francois Doray <fdoray@chromium.org>
Date: Fri Apr 06 19:18:18 2018

Add feature to control whether WebContents occlusion is tracked.

When the feature is disabled, an occluded WebContents behaves like a
visible WebContents.

Before implementing occlusion tracking on Windows, we want to assess
the potential power and speed gains on ChromeOS.
https://docs.google.com/document/d/1Di4DiGwHamIgLYjaOpripOJQinUquUuyxuiim2-WUIs/edit?disco=AAAABqONvy8

Bug: 668690, 818019
Change-Id: I392bfcb81c94a8a651f9d48573ae2a0ad184bd17
Reviewed-on: https://chromium-review.googlesource.com/946520
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Robert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548889}
[modify] https://crrev.com/3f2afbd368796afa238f6950885d2c158cb197f3/content/browser/web_contents/web_contents_impl.cc
[modify] https://crrev.com/3f2afbd368796afa238f6950885d2c158cb197f3/content/browser/web_contents/web_contents_impl_unittest.cc
[modify] https://crrev.com/3f2afbd368796afa238f6950885d2c158cb197f3/content/browser/web_contents/web_contents_view_aura_unittest.cc
[modify] https://crrev.com/3f2afbd368796afa238f6950885d2c158cb197f3/content/public/common/content_features.cc
[modify] https://crrev.com/3f2afbd368796afa238f6950885d2c158cb197f3/content/public/common/content_features.h

Cc: cywang@chromium.org
Cc: -bccheng@chromium.org
fdoray@, sorry for pinging you again but what's left for this? Is this mostly working already, or are these still some missing pieces? There's no activity for like 2-3 weeks.
Blocking: 699559
fdoray@, as I mentioned at https://bugs.chromium.org/p/chromium/issues/detail?id=738387#c63 Chrome OS' foreground tab is not yet properly throttled. Could you share the current status and milestones with us?
Labels: -Type-Bug -Pri-3 Pri-2 Type-Feature

Sign in to add a comment