BartoszCichecki / LenovoLegionToolkit

Lightweight Lenovo Vantage and Hotkeys replacement for Lenovo Legion laptops.
GNU General Public License v3.0
5.03k stars 230 forks source link

[BUG]: Not working properly after new Windows logon #606

Closed FatTonyKS closed 1 year ago

FatTonyKS commented 1 year ago

Version

2.11.0 BETA 5

OS

Win 11 Pro 22H2 22621.1344

Device

Legion 5 Pro 16ARH7H

BIOS version

JUCN57WW

What's wrong?

When my L5P turns off the screen due to inactivity and I wake it up again (new logon in Windows needed), it automatically switches from the custom mode preset to balance mode. I can then also not switch via the shortcuts. Only when I have changed the mode once in the app, then the shortcuts work again. The problem also occurred with the previous beta. Sometimes it is also like this after a restart.

I was able to replay it exactly and record it in the logs.

How to reproduce the bug?

See "What's wrong?"

What is the behavior that you expected?

See "What's wrong?"

Logs

log_2023_03_11_05_37_16.txt

Do you have Lenovo software installed?

Did you disable any Lenovo software using Lenovo Legion Toolkit?

Additional information

No response

BartoszCichecki commented 1 year ago

Could you also upload the automation.json and settings.json file?

So far I can see that EC is changing it's state to Balanced mode, not sure why yet.

You can see it here: [1/03/2023 05:42:56.943] [39] [AbstractWMIListener.cs#87:Handler] Event received. [value=Balanced, listener=ThermalModeListener]

BartoszCichecki commented 1 year ago

What is more interesting is that this apparently happens without you laptop going into sleep mode... So do you mean just that laptop turned off the screen due to inactivity and didn't go into sleep mode?

I can then also not switch via the shortcuts

Also, what does that mean?

BartoszCichecki commented 1 year ago

And last thing, here is a build with a little bit more logging. I can see an obvious reason why this is happening on your machine, so it would be great if you attach logs from this build too. LenovoLegionToolkitSetup.zip

FatTonyKS commented 1 year ago

automation.txt settings.txt

FatTonyKS commented 1 year ago

Thank you for your quick response!

What is more interesting is that this apparently happens without you laptop going into sleep mode... So do you mean just that laptop turned off the screen due to inactivity and didn't go into sleep mode?

Standby is disabled when a power cable is connected. So yes, the monitor goes off, the status LED on the power button blinks. Then, when I wake up the device, I log in (in my case with an external fingerprint sensor), and then the mentioned problem occurs.

I can then also not switch via the shortcuts

Also, what does that mean?

I meant that then also the shortcuts (right click on the icon in the taskbar) do not work. There I have shortcuts for the quick change of the custom mode profiles. Once the profile in the app has been changed, then the shortcuts work again.

And last thing, here is a build with a little bit more logging. I can see an obvious reason why this is happening on your machine, so it would be great if you attach logs from this build too.

I will submit the logs separately.

FatTonyKS commented 1 year ago

log_2023_03_11_13_31_39.txt

FatTonyKS commented 1 year ago

What I just noticed is that when my custom mode profile is active, the power button led is purple. Right after the monitor turns off, the color changes to white and then flashes white. So it seems that the change to balance mode already takes place there.

BartoszCichecki commented 1 year ago

OK I think I am getting some sort of clarity here:

the monitor goes off, the status LED on the power button blinks.

So that means that laptop is going to sleep. That is normal, since while in sleep led is always white.

automation.txt

According to the configuration you have you only have a step to change the Custom Mode preset and as the description says:

image

it will only take effect when Custom Mode is already active. If you want to make a switch to Custom Mode, you need the Power Mode step.

Finally, regarding the power mode switching. I understand that after you wake the laptop it stays in balance, right? The only power mode switch log I can see is that power mode switches because Windows power plan changed:

[11.03.2023 13:33:11.368] [41] [PowerModeFeature.cs#39:SetStateAsync] XXXX Balance, trace:    at void System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start<TStateMachine>(ref TStateMachine stateMachine)
   at Task LenovoLegionToolkit.Lib.Features.PowerModeFeature.SetStateAsync(PowerModeState state)
   at async Task LenovoLegionToolkit.Lib.Listeners.PowerPlanListener.OnChangedAsync()

I am not sure why your laptop changes the power plan, but it's not caused by LLT. Maybe you have LFC or some other software isntalled?

FatTonyKS commented 1 year ago

All right, I understand about the shortcuts. I have adjusted these and that's how it works now:

Screenshot 2023-03-11 161343

So this problem is solved. I obviously didn't read the discription carefully enough. Thank you!

Finally, regarding the power mode switching. I understand that after you wake the laptop it stays in balance, right?

Yes.

Maybe you have LFC or some other software isntalled?

Nothing like this. Clean windows install. Vantage or LFC has never been on this installation. The only Lenovo tools are "System Update" and "Service Bridge".

BartoszCichecki commented 1 year ago

I don't think I will be able to help here much. You need to find out why power plan changes - this is the reason why LLT changes power mode.

FatTonyKS commented 1 year ago

I have tried two things in the meantime:

  1. I uninstalled Toolkit. When I am in Quiet mode, it does not switch to Balance mode during standby.

  2. I installed Toolkit again. If I am then in Quiet mode, it also does not switch to Balance mode during standby.

It obviously only happens when the custom mode is selected.

BartoszCichecki commented 1 year ago

during standby.

This is something that you need to make a lot more specific, because no logs you send contain information about laptop going into sleep or resuming (which LLT monitors). So what does "during standby" mean specifically?

FatTonyKS commented 1 year ago

Then I will write down the problem again in detail:

  1. Toolkit is running in custom power mode. The LED is purple.

  2. The monitor goes off due to inactivity. The LED flashes white.

  3. When I wake up the system again, the login screen appears. There, the LED briefly lights up purple again, but then immediately changes to white.

After the Windows login, the toolkit shows the balance mode and I have to manually switch to the custom mode again.

Both logs were recorded during exactly this process. They definitely contain the short standby state including the wake-up.

Thanks in advance for your help!

By the way, I'm not quite sure if the definition "standby" is correct here. Just so we don't talk past each other: What is meant is what happens when you set the following in Windows (here the German version):

Screenshot 2023-03-13 051225

FatTonyKS commented 1 year ago

There is another idea from Hardwareluxx forum:

Could you maybe call the custom profile through a script? Then you could run this script when you log in to Windows. Alternatively, a shortcut solution would also be conceivable.

BartoszCichecki commented 1 year ago

2. The LED flashes white

What is meant is what happens when you set the following in Windows (here the German version)

This would indicate that laptop is going into sleep mode and for some reason the Windows is not reporting power state changes on your machine. The log does not contain anything indicated that the system went to sleep.

Here is a line from log captured on my machine:

[16/03/2023 07:41:33.572] [36] [PowerStateListener.cs#55:SystemEvents_PowerModeChanged] Event received. [e.Mode=Suspend, newState=Connected]

which is completely missing from your log. I have no clue why.

Then you could run this script when you log in to Windows.

Since there is no point of reference in your log when your laptop resumes for sleep, not sure if that would help. You earlier wrote:

When I wake up the system again, the login screen appears. There, the LED briefly lights up purple again, but then immediately changes to white.

It look like that for whatever reason the change occurs when laptop resumes although as I said, sleep/resume isn't logged on your machine for whatever reason. BUT the only place in the log that suggests a change is that a power plan has changed.

HOWEVER,

This gave me an idea. You have a Gen7 AMD Legion. Did your Legion come with the 3 Windows Power Plans for balanced, quiet and performance or did you import them manually? Does your machine have S0 sleep enabled? You can check it with powercfg /a.

FatTonyKS commented 1 year ago

I have reinstalled Win 11 and imported the power plans manually afterwards. But to be honest, I don't know if they were already installed (automatically?) before.

S3 is activated for me. All others are mentioned as "not supported".

BartoszCichecki commented 1 year ago

Then I really have no clue. I am asking because Moden Standby (S0) enabled machines do not support "performance" power plans: they come from factory with only one Balanced power plan. People still import all 3 and that causes weird behaviours. Your issue could be explained by this, since Custom Mode by default uses the performance power plan and with Modern Standby enabled, Windows will randomly revert to Balanced plan anyway.

If S0 sleep is not enabled for you then this is not it. Can you check anyway if situation will change if in LLT settings at the bottom you change the power plan for Custom Mode from (Default) to Legion Balanced?

Reference: https://learn.microsoft.com/en-us/windows/win32/power/power-policy-settings

BartoszCichecki commented 1 year ago

Related issue: #614

FatTonyKS commented 1 year ago

Can you check anyway if situation will change if in LLT settings at the bottom you change the power plan for Custom Mode from (Default) to Legion Balanced?

When I set it like this...

Screenshot 2023-03-16 195226

... then the power plan is not changed after waking up the system!

Is that the solution for me or is there any disadvantage when setting it like this?

BartoszCichecki commented 1 year ago

That means that your system has Modern Standby enabled and windows is actively reverting back to the Balanced. You can find more details (although not a lot) in the Microsoft link above. It also means that performance plans aren't supported properly on your laptop. Don't ask the details, because I don't know - Microsoft is not very open about the how's and why's.

BartoszCichecki commented 1 year ago

As a sidenote I will change the defaults and also add a warning on Modern Standby systems in issue #614.