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

Issue 644348 link

Starred by 4 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocked on:
issue 702449
issue 679062

Blocking:
issue 629707
issue 770866
issue 648962



Sign in to add a comment

mash dbus: Power manager support (powerd, PowerManagerClient)

Project Member Reported by jamescook@chromium.org, Sep 6 2016

Issue description

powerd provides D-Bus APIs used by the Chrome browser process. go/dbus-in-mustash

Used in chrome (e.g. reboot from login screen webui or from enterprise policy remote command)
Used in ash (e.g. shutdown button in system tray)
Will need to use in mus window server (video activity)

Almost all of this code is agnostic about having multiple clients speaking to powerd. It listens for a bunch of signals and notifies observers, along with making asynchronous method calls to powerd. It also registers for notifications of imminent suspend events, but powerd already supports multiple processes doing this. It's probably fine to be running most of this in parallel in both ash and Chrome.

The calls to powerd's HandlePowerButtonAcknowledgment method (in response to InputEvent signals from powerd) should only happen in one process; presumably that'd be ash (since that's what actually deals with the events). I don't think that we actually use the acks for anything, though; they were initially added to support capturing data and rebooting the device when the UI is hanging ( crbug.com/298983 ), but the firmware side of this was never implemented ( crbug.com/341547 ).

The one thing that really needs to change is chromeos::PowerPolicyController. This class consolidates a bunch of different browser prefs (typically set via enterprise policies) and wake locks into a single protobuf describing the desired power-management behavior, which it then ships off to powerd. It'd be bad if both ash and Chrome were sending these. Luckily, I think that it's only used by the browser (and content/), so it should probably only be instantiated in Chrome. Note that ARC++ also creates wake locks now. (They show up in the power policy as if an extension had requested them, so it shouldn't be a problem here.)

Plan: Convert to support multiple clients (chrome, ash, mus-ws)

 
Cc: sadrul@chromium.org anicolao@chromium.org rjkroege@chromium.org osh...@chromium.org
 Issue 602686  has been merged into this issue.

Comment 2 by derat@chromium.org, Sep 6 2016

Owner: derat@chromium.org
Status: Assigned (was: Untriaged)
A nice start might be to make the shutdown button in the ash system tray work properly.

(There will probably be shutdown crashes in chrome and ash, but it would be good to know about those.)

Comment 4 by derat@chromium.org, Sep 6 2016

Re #3, is ash currently not instantiating a DBusThreadManager at all?
Ash creates one here:
https://cs.chromium.org/chromium/src/ash/mus/window_manager_application.cc?type=cs&q=f:mus+dbus&sq=package:chromium&l=47

I'm looking at making ash only initialize a subset of dbus clients, see  issue 644414 . For now, though, it's initializing everything, including powerd stuff.


Project Member

Comment 6 by bugdroid1@chromium.org, Sep 15 2016

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

commit bc32dfbb9d481c8d93efe038569f3a6d81267db5
Author: msw <msw@chromium.org>
Date: Thu Sep 15 00:52:17 2016

mash: Fix Chrome crash accessing chrome://settings.

Avoid Shell and PowerStatus access for display/power options.

BUG= 646558 , 548429 ,644348
TEST=No crash accessing chrome://settings in chrome --mash.
R=stevenjb@chromium.org

Review-Url: https://codereview.chromium.org/2341783005
Cr-Commit-Position: refs/heads/master@{#418731}

[modify] https://crrev.com/bc32dfbb9d481c8d93efe038569f3a6d81267db5/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
[modify] https://crrev.com/bc32dfbb9d481c8d93efe038569f3a6d81267db5/chrome/browser/ui/webui/options/chromeos/power_handler.cc

Comment 7 by derat@chromium.org, Sep 15 2016

Is this primarily a tracking bug? I'm trying to figure out what needs to be done at this point.

James, have you decided what route you're advocating for clients that probably need to be present in both arc and Chrome? If most of the code will used by both processes, should I add an enum parameter to the client class's c'tor with values like ASH, BROWSER, and BOTH? That seems not-great, in that it's tough for a caller to know whether a given method will be callable or not. Do you prefer for this code to be split into multiple clients instead?
Cc: hashimoto@chromium.org steve...@chromium.org
+stevenjb, hashimoto. I'm working right now on how to split up dbus clients between processes. WIP CL: https://codereview.chromium.org/2343993003

This is mostly a tracking bug. I don't personally know powerd well enough to know what won't work.

Any thoughts on how to handle ash::PowerStatus?

I'm working on some code in SystemTrayDelegateChromeos that uses ash::PowerStatus::Get(). This particular piece of code I can migrate into ash, but it seems like both the ash and the browser process will need to know about battery state. Could PowerStatus be factored into someplace shared (down in //chromeos/) and get updated by powerd in both processes?

Comment 10 by derat@chromium.org, Sep 27 2016

Cc: michae...@chromium.org
#9: ash::PowerStatus currently mostly just caches the latest PowerSupplyProperties proto received from powerd and provides convenience methods on top of it. Many of those methods are very UI-specific, though (strings, icons, ugh even a display dependency to get the scale factor, etc.), so I think it might be hard to move it into chromeos/ without splitting the UI-specific bits into another class that lives somewhere else.

After glancing through the code, I'm not convinced that the browser process needs this. I see chrome/browser/ui/ash/system_tray_delegate_chromeos.cc using it, but that looks like it's maybe just to display the power settings on behalf of ash.

I don't know what the plan is for where settings should live, but there _is_ a PowerStatus::SetPowerSource() method that calls powerd via PowerManagerClient. It looks like it's only used by chrome/browser/ui/webui/options/chromeos/power_handler.cc, and there's maybe not any good reason for it to exist.
Hmm. We've got //ash/shared for simple code that can be shared between //chrome and //ash, but I see PowerState also has an ash/common/material_design_controller.h dependency.

WebUI settings will continue to live in Chrome, so we're going to need some way to poke powerd from WebUI, then get an update in ash.

Comment 12 by derat@chromium.org, Sep 28 2016

More-concrete proposal:

a) The UI-independent parts of PowerStatus should live under //chromeos.
b) GetAccessibleNameString and everything with *BatteryImage* in its name should live in //ash since I think that's the only place they're used.
c) PowerStatus::SetPowerSource() should go away because it's just a wrapper around PowerManagerClient's method. The same argument could be made for PowerStatus::RequestStatusUpdate().

For a), it seems reasonable (and maybe desirable) to rename the class to something like PowerStatusWatcher and make it not be a singleton. If we keep it as a singleton, it's basically 1:1 with PowerManagerClient (registers as an observer of it and caches/interprets a proto from it).
Project Member

Comment 13 by bugdroid1@chromium.org, Sep 29 2016

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

commit d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f
Author: jamescook <jamescook@chromium.org>
Date: Thu Sep 29 20:31:08 2016

Support SystemTrayDelegate::ShowPowerSettings() in mustash

* Wire through SystemTrayDelegateMus -> mojom::SystemTrayClient -> SystemTrayCommon
* To avoid ash dependencies in SystemTrayCommon, check for a battery in the //ash
code, which has access to ash::PowerStatus
* Remove the check for the --enable-power-overlay switch, since this code is only
triggered from DualRoleNotification in ash, which only occurs on a real device

BUG=644348, 647412 
TEST=manual, change the code to call ShowPowerSettings when clicking on the
tray date and observe that power settings opens

Review-Url: https://codereview.chromium.org/2377703003
Cr-Commit-Position: refs/heads/master@{#421923}

[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/ash/mus/system_tray_delegate_mus.cc
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/ash/public/interfaces/system_tray.mojom
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/chrome/browser/ui/ash/system_tray_client.cc
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/chrome/browser/ui/ash/system_tray_client.h
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/chrome/browser/ui/ash/system_tray_common.cc
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/chrome/browser/ui/ash/system_tray_common.h
[modify] https://crrev.com/d2de27ad565eae8ca5e3c61cc055ecb34e4e1b3f/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Labels: Proj-Mustash
Components: Internals>MUS
FYI I'm doing some work to move more shutdown handling code out of chrome and into ash as part of my work on  issue 647412  (SystemTrayDelegate for mustash).

Project Member

Comment 17 by bugdroid1@chromium.org, Nov 10 2016

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

commit 04570b6023aeada35ead88f6488618be307793d1
Author: jamescook <jamescook@chromium.org>
Date: Thu Nov 10 19:51:59 2016

chromeos: Move SystemTrayDelegate::RequestShutdown to WmShell

For mustash the chrome browser process cannot call directly into ash. The
implementation of this method in chrome's SystemTrayDelegateChromeos just
turns around and calls into ash::LockStateController.

Moving the method allows ash to process these requests internally. The mus
implementation is still NOTIMPLEMENTED because we don't have mus support
for LockStateController and its animations.

After removing another unused method this results in SystemTrayDelegateChromeos
having no ash::Shell references. (It still uses ash::WmShell, though.)

This is part 1 of moving shutdown handling out of chrome into ash.

BUG=644348,  647412 
TEST=Shutdown from system tray still works in classic ash

Review-Url: https://codereview.chromium.org/2491403003
Cr-Commit-Position: refs/heads/master@{#431323}

[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/aura/wm_shell_aura.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/aura/wm_shell_aura.h
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/common/system/date/date_default_view.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/common/system/tiles/tiles_default_view.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/common/system/tray/system_tray_delegate.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/common/system/tray/system_tray_delegate.h
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/common/wm_shell.h
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/mus/bridge/wm_shell_mus.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/ash/mus/bridge/wm_shell_mus.h
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/chrome/browser/ui/ash/system_tray_delegate_chromeos.h
[modify] https://crrev.com/04570b6023aeada35ead88f6488618be307793d1/chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc

Blockedon: 679062
Blocking: 648962
Cc: jonr...@chromium.org

Comment 21 by derat@chromium.org, Mar 17 2017

Blockedon: 702449
Blocking: 770866
Components: -Internals>MUS Internals>Services>WindowService
Components: -MUS
Components: -Internals>Services>WindowService Internals>Services>Ash
Labels: -Proj-Mustash-Mash
Labels: -Proj-Mustash-Mus-WS
Deprecating Proj-Mustash-Mus-WS label in favor of Components.
Labels: -Proj-Mustash -Proj-Mustash-Chrome Proj-Mash-MultiProcess
Bug label cleanup.

PowerPrefs got moved to ash by https://crrev.com/c/986889 for issue 812504. I think that the main thing remaining here is to make sure that all wake locks get consolidated in the PowerPrefs instance owned by ash. Wake locks go through the device service, IIRC, but I'm not sure of the current state (fate?) of that service. If it lives in ash, this might just work already.

Sign in to add a comment