Skip to content

Fix torn fan readings, tooltip truncation, driver inventory crash, release check - #13

Closed
fisherjdjdj wants to merge 7 commits into
Wintego:mainfrom
fisherjdjdj:patch/sensor-robustness
Closed

fisherjdjdj wants to merge 7 commits into
Wintego:mainfrom
fisherjdjdj:patch/sensor-robustness

Conversation

@fisherjdjdj

@fisherjdjdj fisherjdjdj commented Sep 28, 2026 •

Copy link
Copy Markdown

What this fixes

Four defects and two missing sensors found while investigating "power is not detected" and
"the fans look broken" on a HONOR MagicBook (FMB-P, Core Ultra 5 225H, BIOS 1.16,
Windows 11 26100) running 1.11.1. Every claim below is measured on that machine with the
shipped build as the control; the measurement scripts are listed at the end.

Related issue: #14 — the battery-power wording that started this investigation. The other
sections are written to stand on their own: each defect below carries the measurements it
came from, so nothing here depends on reading another issue. §5–§6 continue the fan thread
(they are why the ceiling quoted in §1 changed again).

1. Fan speed reaches the tooltip unfiltered (HardwareSensors.cs, HardwareSettings.cs)

The EC latches the tachometer value about once a second. A read that lands on the
update returns a torn value, and the corrupt bytes survive the whole window, so
reading several times inside one refresh repeats the same impossible number. Raw
OemWMIfun reads, no app involved, CPU at 98 °C:

pair 2: slot0  53645  53645          slot1  1992  1992      <- one window, both reads
40 fast reads of slot0:
  93 93 93 93 93 93 93 94 94 94 94 95 95 95 95 95 92 92 92 3392 3392 3392 93 93 ...

A later run caught 34482 the same way, and 1.11.1 flashed 0 RPM twice while the fan
was spinning at 1760-2650 RPM in the same seconds.

The commit takes two reads per refresh one latch window apart, drops values above
10000 RPM outright, and shows the median of the last five samples (~12 s), kept in
HKCU\Software\HonorPCHelper\FanRpmHistory so the next hover adds to the same window.

Follow-up commits in this same PR replace the 10000 ceiling (see §5): the bound is now
6500 RPM, and a value only counts when a second sample in the window lies within 10% of it
(never closer than 200 RPM) — a tear is a number nothing else agrees with, so corroboration
catches the 5560 and 7547 cases that walked straight through 10000.

raw EC slot0     : 2142 2656 1961 1762 2400 2949 2210 2253 2819 3316
1.11.1           : 1986 2656    0    0 2881 3091 2210 2714 2894 3316
patched          : 3021 2262 2063 2382 2919 2949 2407 2714 2726 2726

largest jump between consecutive tooltip values: 1.11.1 = 2656, patched = 759
impossible readings: 1.11.1 = 2/10, patched = 0/10
one refresh: 0.4 s -> 1.4 s (the tray waits up to 5 s, so it still fits)

Two trade-offs I want on the record rather than buried: a real ramp is followed about
one refresh late, and 0 is not treated as invalid on this model because the first fan
genuinely idles near a stop (90 RPM at rest, 0 when cold). If you would rather keep the
lag out and only discard impossible magnitudes, that is the smaller half of the commit.

2. Russian tooltip overruns 127 characters and loses the readings (DiagnosticsService.cs)

NotifyIcon.Text takes 127 characters and the builder cuts at exactly that index. The
Russian text needs 153 characters in performance mode with the sensor lines present, so
the tooltip ended mid-word and showed no fan numbers at all — measured by calling the
shipped builder through reflection:

ru-RU 1.11.1 shows : "… | CPU: 62°C; батарея: 33°C | Ве"
ru-RU patched      : "Реж.: произв. | Свет: сильная | Огр. заряда: 95–100% | Бат.: 0 Вт, без тока
                      | CPU: 62°C; бат.: 33°C | Вент.: 123/2405 об/мин"   (119 chars)
en-US 125 / zh-CN 78 characters: unchanged, full labels still fit

The text is rebuilt once with short Russian labels when it overflows, and only trimmed
to whole lines if that still does not fit. Wording part of the same commit: the power
line is the battery's charge/discharge rate, not the machine's draw, so the label says
Battery and a battery held inside its charge range says 0 W, idle instead of a bare
0 W — that ambiguity is exactly what made me think the sensor path was broken.

3. Driver inventory throws NullReferenceException (DriverUpdateService.cs)

The missing-device query runs forward-only (Rewindable = false) and then sorts the
live ManagementObject sequence. OrderBy buffers by enumerating first, and the
enumerator releases each row as it moves on, so the key selector runs over rows that are
already gone. This machine has one such row — ROOT\SYSTEM\0002 with no Name and no
PNPClass — and it takes the entire inventory down:

2026-09-27 21:12:04 [ERROR] Initial driver device inventory failed; retrying |
    System.NullReferenceException ... DriverUpdateService.<ReadInstalledComponents>b__15_27
2026-09-27 21:12:05 [INFO] Checking HONOR driver updates for FermatB/C233; 0 detected, 22 requested

Copying the three values while enumerating and sorting the copies (the pattern the other
queries in the same file already use) gives RESULT: OK, components detected = 20 from
the same call at the same moment.

4. A throttled release check becomes an error entry (ApplicationUpdateService.cs, ApplicationUpdateWatcher.cs)

EnsureSuccessStatusCode() turned a 502 from the releases API into an ERROR line in
the log users are asked to send. Returning an empty ApplicationUpdateCheck instead
would be wrong — the watcher publishes .Update, so a transient failure would clear a
"Update to 1.12.0" that a successful check had already found. CheckAsync now returns
ApplicationUpdateCheck?, with null meaning "this round said nothing", which is what
both call sites already did on the exception path; the log line drops to INFO.

Two more sensors the firmware already exposes: memory temperature and fan duty

5. HardwareSensors.cs, DiagnosticsService.cs — what the EC answers that we were not asking

I decompiled this machine's ACPI tables (acpidump -b + iasl -d, read-only) because
"no interface exists" was doing a lot of work in my diagnosis. OemWMIfun's 64-byte input
turns out to be byte[0] = main function, byte[1] = sub function, byte[2] = index, and the
out[0] = 1 we both treat as "BIOS refused" is the AML Default branch — the EC never saw
those reads. Two consequences the app can use today:

GTMP (0x0202) has a memory zone. The switch over the index byte names CDTS (CPU,
0x00), DDRS (memory, 0x0B) and BTND (battery, 0x0E) among others. On this machine
0x0B is the sensor the right fan actually ramps for — it is what explains a fan rising
while the CPU line looks flat — so the tooltip now carries it next to the battery
temperature. Measured 45–49 °C idle, 53–59 °C during the event that opened this report.

GCFD (function 4 / sub 0x17) returns the PWM duty each fan is being driven with, and
it is ungated. Calibrating it against the tachometer, 319 one-second samples:

duty 30 -> 2167..2203 RPM (mean 2179)   RPM per duty point = 72.6
duty 28 -> 2006..2031 RPM (mean 2023)   RPM per duty point = 72.2

That rewrites the conclusion of §1: the highest speed this machine ever reported, 3303 RPM,
is ~45% duty, not the fan's ceiling — the EC was never asked for more. And it separates two
things the speed line alone cannot:

raw OemWMIfun 0x1704, index 0 -> 00 01 64 64   enabled, duty 100%
raw OemWMIfun 0x1704, index 1 -> 00 01 1C 64   enabled, duty 28%
live tooltip (zh-CN, read off the tray icon through UI Automation, 111 chars):
  风扇:92/2002 转/分,占空 100/28%

The left fan reports 94–117 RPM all day while its duty says 97–100%. Which of the two is
lying is still open on this unit — but with both on screen, "the fan stopped" and "this
model's speed readout is broken" are no longer the same tooltip, and the duty stays valid
in the exact refresh where the median of speeds correctly refuses to guess. Both readings
are appended to the snapshot, so a snapshot written by an older build still parses with the
new sensors unknown rather than dropping every hardware line.

The 127-character budget from §2 still holds with both additions: Chinese measures 111
characters live, and rebuilding the same label table gives 115 (compact) / 120 (full
labels) for Russian and 121 for English, so Russian users land on the short-label variant.

6. HonorWmi.cs — read and write paths could pick different WMI instances

GetInstance() took FirstOrDefault() out of root\wmi\OemWMIMethod, while the privileged
write path prefers the HWMI_0 instance, so the two could otherwise disagree about which
device they were talking to. The read path now pins HWMI_0 and only falls back to the
first instance if it is missing. Both instances answered identically on this machine, so
this is consistency rather than a reproduced defect.

Not included

TouchpadVendorLink.SupportedDevices does not contain this machine's pad, so the
Touchpad menu is hidden here. The device is ACPI\BLTP785 = 347D:7853, and its
vendor collection passes every other test in FindDeviceCore
(UsagePage 0xFF00, Usage 0x0001, OutputReportLength 33). I deliberately did not
add it: I never sent a vendor report to the pad, so I cannot confirm haptics and edge
gestures actually respond on this model. Filed separately.

How to verify

dotnet build -c Release — 0 warnings, 0 errors on .NET 10.0 SDK.
Behaviour was checked with four small harnesses (reflection over the shipped private
members, so nothing in the app had to be made public for testing): alternating
stock/patched --read-sensors rounds against raw OemWMIfun probes for the fan series,
DiagnosticsService.BuildCompactToolTip() per culture for the character counts, and
DriverUpdateService.ReadInstalledComponents() before and after.

The HONOR EC latches the tachometer value about once a second. A read that
lands on the update returns an impossible number, and the corrupt bytes
survive the whole latch window, so reading several times inside one refresh
repeats the same bad value rather than averaging it out. Measured on a
FMB-P (Core Ultra 5 225H): raw reads of 53645 and 34482 RPM while the fan
spun near 2000, and 1.11.1 flashed 0 RPM twice in ten seconds of a spinning
fan.

Take two reads per refresh one latch window apart, drop values above
10000 RPM, and show the median of the last five samples (~12 s), kept in
HKCU\Software\HonorPCHelper\FanRpmHistory so the next hover adds to the
same window. Largest jump between tooltip values drops from 2656 to 759
RPM and no impossible reading survives, at 1.4 s per refresh against the
five seconds the tray waits for. A real ramp is followed about one refresh
late, which the comment in the code spells out.
NotifyIcon.Text accepts at most 127 characters and the builder cut the
string at exactly that index, so the Russian text - 153 characters in
performance mode with the sensor lines present - ended mid-word and showed
no fan numbers at all. Rebuild once with short Russian labels when the
text overflows, and trim to whole lines only if that still does not fit.
Measured against the shipped builder: ru 153 -> 119 characters with all six
lines, en 125 and zh 78 unchanged.

The power line is the battery charge/discharge rate, not the machine draw,
and a battery held inside its charge range legitimately reports neither,
so the label says Battery and a zero rate says so instead of showing a
bare "0 W".
The searcher runs forward-only, so each row is released as the enumerator
moves on. Sorting the live ManagementObject sequence ran the key selector
over rows that were already gone: on a machine with an orphaned device
(ROOT\SYSTEM\0002, CM_PROB_FAILED_INSTALL, with no Name and no PNPClass)
the whole driver inventory threw a NullReferenceException, which the shipped
log records as "Initial driver device inventory failed" followed by
"0 detected, 22 requested". Copy the three values while enumerating and
sort the copies, the pattern the other queries in this file already use.
EnsureSuccessStatusCode turned a 502 from the releases API into an ERROR
entry in the log users are asked to send. Returning an empty
ApplicationUpdateCheck would have been worse: the watcher publishes
.Update, so a transient failure would clear an update a successful check
had already found. CheckAsync now returns a nullable result where null
means "this round said nothing", which is exactly what both call sites
already did on the exception path, and the log line drops to INFO.
Decompiling the ACPI tables (acpidump + iasl) showed that OemWMIfun's input
bytes are a main/sub function pair, and that GTMP's zone byte is a fixed
table: 0x00 CDTS (CPU package), 0x0B DDRS (memory), 0x0E BTND (battery),
0x21..0x28 skin temperatures. Zones outside the table return status 1 from
the AML Default branch, so those "BIOS rejected it" readings were never EC
errors. Report DDRS alongside CPU and battery: it is the sensor the right
fan actually ramps for, so it explains noise the package temperature does
not.

Fan filtering kept 5560 and 7547 RPM on a machine whose measured envelope
is 0..3303, because a torn latch is only rejected above 10000. Drop the
ceiling to the physical envelope and require a second sample in the window
to agree: a tear is a number nothing else corroborates, and in a five
sample window it is also the median, so a ceiling alone cannot catch it.

Both fan tach bytes are read from separate EC offsets, so a reading below
256 is a fan at the bottom of its range rather than one turning at 130 RPM.
Say so instead of showing a number that reads as a broken fan.

Also pin the same WMI instance for reads that the write path already pins:
the two can otherwise disagree about which HWMI device they are talking to.
Decompiling the ACPI tables showed GCFD (function 4/sub 0x17), which returns
the enable flag and the current duty for a fan. Calibrated against the tach on
a FMB-P over 319 one-second samples, RPM = 72.5 x duty +/- 0.9.

That matters for the machines the speed readout cannot describe: one fan
reports 94-117 RPM at a duty of 97-100%, so "it barely spins" was never a
statement about the fan. The duty also stays valid across a torn latch window,
where the median of speeds correctly refuses to guess, so the tooltip has
something to show instead of "?" for a refresh.

Snapshot fields are appended, so a snapshot written by an older helper still
parses with the new sensors left unknown.
The left fan's duty and its speed readout disagree, and which of the two is
lying has not been settled - the comment claimed the duty was the exact one.
What is actually established is that the two are independent readings and the
duty never tears.
@Wintego

Wintego commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Thanks for this, it's one of the most carefully measured PRs this repo has had. I read the whole diff, and the branch builds clean on my side.

I'd like to split it, because the parts carry very different risk:

Happy to merge as-is:

  • Driver inventory NRE: sorting the live forward-only ManagementObject sequence is a real bug, and copying the values first is the right fix.
  • CheckAsync returning null on a non-success status. Both call sites already handle it, and it keeps a found update from being cleared.
  • Tooltip length: the compact Russian rebuild, trimming to whole lines, and the Battery / 0 W, idle wording from Tooltip "Power: 0 W" is the battery rate, and a held battery is not explained #14.
  • Pinning HWMI_0 on the read path.

Would like to hold back for now:

  1. 0x1704 (GCFD). This now runs on every model the app supports. It sits in group 0x04, next to 0x0F04, which is a write (power unlock). The existing codes don't follow any get/set pattern I could rely on: 0x11 is a read for battery thresholds and a write for the backlight timeout. Could you paste the decompiled AML for the GCFD branch (the 0x04/0x17 case and what it touches)? Without that, I'd rather not send an unknown sub-function to firmware on machines nobody has tested.
  2. RPM smoothing. The extra 1.1 s Thread.Sleep on every refresh, the registry history and the corroborated median are a lot of machinery built from one unit. The trade-offs you listed yourself (lag, ? during a ramp) are the ones I'm wary of. I'd take the smaller half you offered: drop readings above a plausibility bound, no median and no extra round.
  3. Duty in the tooltip. With the left fan at ~100 RPM and 97–100 % duty, and the open question of which reading is wrong, I don't want to show users a number we can't vouch for yet.
  4. Memory temperature (0x0B). Same concern: it's verified on FMB-P only.

Could you split this into two PRs: one with the fixes above and one with the new sensors? I'll merge the first quickly. For the second, data from another model or the AML excerpts would go a long way. Gating the new reads behind a list of verified models would also work for me.

@Wintego

Wintego commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Update: the driver NRE, release-check and HWMI_0 fixes landed in 1.13.1 (13a99fb, d0734f6), the battery wording in 1.13.3. Main already handles tooltip overflow differently, so the compact-label rebuild isn't needed. What's left here is the new sensors; same conditions as before (AML for GCFD or data from another model). Please rebase onto main with only those.

@Wintego

Wintego commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Closing since the fixes are in main (1.13.1, 1.13.3). For the sensors, please open a fresh PR against current main — ideally gated to verified models, with the GCFD AML excerpt. Thanks for the thorough work.

@Wintego Wintego closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants