Bug 490239

Summary: Energy Page: Sometimes Cannot Display Battery Change Percentage Graph
Product: [Applications] kinfocenter Reporter: Eamonn Rea <eamonnrea>
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: nate, postix, sitter
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 6.4
Sentry Crash Report:

Description Eamonn Rea 2024-07-13 17:37:37 UTC
SUMMARY
Sometimes the "Energy" information's Change Percentage tab for my laptop cannot display its graph. There is a bubble that says "This type of history is currently not available for this device".  Swapping between the "Change Percentage" and "Energy Consumption" info will eventually get the graph to display.

This issue usually happens after taking my laptop from sleep, even just putting it to sleep briefly (less than a minute). Waking from sleep doesn't seem to fix the issue.

When running from the commandline in my case, I was able to see these errors. The first one was printed when I opened the "Energy" tab, so that was from a "first load" of the page. The other two were after I switched to the "Energy Consumption" tab and then back to the "Change Percentage" tab (they are buttons but act like tabs, sorry if I used the wrong phrasing, unsure how to describe them).

```
qrc:/kcm/kcm_energyinfo/Graph.qml:56: TypeError: Cannot read property 'x' of undefined
qrc:/kcm/kcm_energyinfo/Graph.qml:118: TypeError: Cannot read property 'x' of undefined
qrc:/kcm/kcm_energyinfo/Graph.qml:118: TypeError: Cannot read property 'x' of undefined
```

STEPS TO REPRODUCE
1. Open Info Center after a device with a battery has been put to sleep
2. Open the Energy pane
3. Sometimes the "Change Percentage" graph cannot be loaded.
4. Swap between "Energy Consumption" and "Change Percentage"
5. Eventually, the graph should load, it can take a long time though.

OBSERVED RESULT
Energy Consumption can sometimes not be displayed after taking a device with a battery from sleep.

EXPECTED RESULT
The information should be available. Maybe this as straightforward as passing some data differently to the graph. Otherwise, Plasma could either try to fetch it and show some kind of loading placeholder for the graph with a spinner.

Reading the error again, "not currently available" does seem to have an implication that the data may be available in future. So perhaps this error was placed with the intent to convey that the data should be present, but Plasma couldn't get it right now. In that case, maybe adding a "please try again later" or something to this effect would be good, to indicate that Plasma does know it should display this information for this device, but that it cannot right now.

I am not sure if Plasma displays the same warning on a Desktop PC without a battery connected, but if it does, ideally the two warnings should be distinct; something indicating that in this case, the battery is known to be present, but that Plasma just cannot get the requested information for the graph right now.

But again, if it is possible to fix this outright, that should be preferred :-)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 6.9.8 Linux Zen
KDE Plasma Version: 6.1.2
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
Looking at master, I guess this is `plot` that is undefined: https://invent.kde.org/plasma/kinfocenter/-/blob/be18d5e78711dfa5ddc5a85f90c59fa197ac083d/kcms/energy/ui/Graph.qml#L56

From skimming the code maybe it isn't able to load some data, which is causing the graph to not display? Maybe there is a deeper firmware issue or something causing this behaviour, I am unsure (although powertop can display battery information fine so I am unsure).

Or maybe it takes a while to fetch some of this information / it has to be re-prompted to fetch it, which might be why switching between the two pages with the two graphs eventually gets the information to display? That would mean it isn't necessarily switching the pages that fixes the problem, but that switching them means that effectively the data the Change Percentage page needs has finally loaded and so going back to the page acts like a "refresh" action.

I am unsure, I'm not super familiar with the technology here :-)

If there are any files I can provide, such as cache files like for a prior issue with QML errors, let me know what to provide and the next time I can reproduce this problem I will attach the necessary files.
Comment 1 Bug Janitor Service 2025-01-30 23:25:51 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kinfocenter/-/merge_requests/220
Comment 2 Ismael Asensio 2025-01-31 16:18:05 UTC
Git commit 2067b2abf6f22ddc5fa1b4edc75f9add0e8b5de7 by Ismael Asensio.
Committed on 31/01/2025 at 16:12.
Pushed by iasensio into branch 'master'.

kcms/energy: More stable UI for history graph

For devices that have history data available, always show the graph.
If there are no data points for the selected time range, simply show
a placeholder message instead of hiding it.

On the other hand, always hide the graph and options for those devices
that cannot provide a history, removing also the potentially confusing
warning message

This moves away from having an annoyingly jumping an unclear UI.
FIXED-IN: 6.4

M  +20   -18   kcms/energy/ui/Graph.qml
M  +17   -18   kcms/energy/ui/main.qml

https://invent.kde.org/plasma/kinfocenter/-/commit/2067b2abf6f22ddc5fa1b4edc75f9add0e8b5de7