Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new warning in main: Not implemented reached in virtual bool base::PowerMonitorDeviceSource::IsOnBatteryPower #29614

Closed
ckerr opened this issue Jun 9, 2021 · 6 comments

Comments

@ckerr
Copy link
Member

ckerr commented Jun 9, 2021

[2212055:0609/095801.855559:ERROR:power_monitor_device_source_stub.cc(11)] Not implemented reached in virtual bool base::PowerMonitorDeviceSource::IsOnBatteryPower()

@ckerr ckerr self-assigned this Jun 9, 2021
@dsanders11
Copy link
Member

Maybe related to #29291?

@codebytere
Copy link
Member

Looks like this isn't implemented on Linux - we should probably either return false for Linux and update docs

@ckerr
Copy link
Member Author

ckerr commented Jun 17, 2021

So there are at least two things going on here.

One is that #26494 added public support for this function in Electron. 👍 on updating the docs to reflect that it's not supported on Linux. (It's already returning false, albeit with a NOTREACHED() warning when warnings are enabled, via power_monitor_device_source_stub.cc)

Second is that upstream is reaching this codepath on its own as of https://chromium-review.googlesource.com/c/chromium/src/+/2769179 (Merged Mar 25) which now ensures that IsOnBatteryPower() is called from PowerMonitor::Initialize(), which wasn't the case before.

I added a tracer abort(); before the NOTREACHED warning to force a more explicit backtrace. That build crashes as soon as it's started:

#5 0x7fdac3b4e864 abort
#6 0x56125b070b39 uv__cancelled
#7 0x56125ef9a941 base::PowerMonitor::Initialize()
#8 0x56125c7397b3 content::ContentMainRunnerImpl::RunBrowser()
#9 0x56125c73956f content::ContentMainRunnerImpl::Run()
#10 0x56125c7372ec content::RunContentProcess()
#11 0x56125c7373cc content::ContentMain()
#12 0x56125b0864c7 main

Maybe this part should be reported upstream? If I'm reading this correctly, any debug Linux build of Chromium would also hit this error.

@ckerr
Copy link
Member Author

ckerr commented Jun 17, 2021

As an aside, there exists a way to query this that should work on all our supported Linux platforms, even the very old releases.:

dbus-send \
  --print-reply \
  --system \
  --dest=org.freedesktop.UPower \
  /org/freedesktop/UPower \
  org.freedesktop.DBus.Properties.Get \
  string:org.freedesktop.UPower \
  string:OnBattery

(Translated into pseudo-English: "Hello Linux, please ask org.freedesktop.UPower, which is on the system bus, the value of its OnBattery property".) I've confirmed this works on all the Linux platforms Electron supports (Debian 8, Ubuntu 14.04, Fedora 24):

dbus-send-upower-on-battery-debian-8
dbus-send-upower-on-battery-ubuntu-14 04
dbus-send-upower-on-fedora-8

In each of these cases, the property returned false because my battery was charging.

So, I think we can implement this for at least ourselves. Chromium also supports openSUSE 13.3, which I haven't tried yet but II I'd expect the same results there. If so, maybe upstream would also be interested in a power_monitor_device_source_linux.cc for this.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2022

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants