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

1) Unable to enable HDR if is disabled ||||| 2) HdrEnabled attribute always shows True even when HDR is not enabled #4

Open
marshall1210 opened this issue Aug 13, 2024 · 4 comments

Comments

@marshall1210
Copy link

This is my first time ever submitting an issue, please go easy on me if I'm doing something incorrect here. I absolutely love this utility, however the fact that at no point can I get it the enable HDR (from the state of disabled of course) to work is a real bummer. Turning HDR on and off from the command line was the exact use case that led me to the WindowsDisplayManager project.

I am experiencing two issues:

  1. Unable to actually enable HDR at any time using this utility
  2. HdrEnabled attribute always shows True even when HDR is not enabled

cannot-enable-hdr

@marshall1210
Copy link
Author

This is the first time I've ever debugged a powershell script, but it does appear that the reason I am unable to EnableHdr() is because it the utility already thinks it is enabled. As I mentioned previously, The HdrEnabled attribute always shows true on my system, and because of this attribute always saying it is True, I cannot successfully call EnableHdr().

Hope this helps.

image

@patrick-theprogrammer
Copy link
Owner

patrick-theprogrammer commented Nov 8, 2024

Thanks for your interest in my project and for the debug details!

Sorry for the delay- I haven't had much time for this project since I started it. Life has gotten in the way so far this year, but hoping to find some time to give this a little TLC soon.

In the meantime would you be able to provide debug logs? You can set a debug log level to get a much more verbose output from the tool. This might give us a bit more detail on the unexpected HDR state.

I'm using PowerShell framework as a dependency to handle logging. Hacky but easy way to set debug log level is run Set-PSFConfig -FullName PSFramework.Message.Info.Maximum -Value 8 before using the tool. I'd just recommend setting it back to 3 when you are done otherwise any other PowerShell modules you may have running will keep writing debug logs and may slow down.

More details here:
https://psframework.org/documentation/documents/psframework/logging/basics/message-levels.html

If we can't find a root cause then in the least I think I should add a force option to just ignore what we think the current state is and try to change it anyways.

@spckayak
Copy link

spckayak commented Nov 20, 2024

Hi Patrick

Just wanted to say I am also having the same issue with EnableHdr(). The code thinks HDR is enabled when it really isn't. I think your suggestion to just bypass the function might be an easy fix

Thanks again for this code! It's awesome. I attached a screenshot of what I see. In between the $primaryDisplay commands I manually triggered HDR, and regardless it was always showing as True.

I noticed in your code, you have a message for

"HDR enablement state is already $enablement for target $($this.FriendlyName), nothing to change".

Which is being displayed whenever .EnableHDR() is ran. This tells me the function is being called correctly. A quick fix would maybe be to overwrite this if statement:

if ($currentHdrInfo.HdrEnabled -eq $enablement) { Write-PSFMessage -Level Debug -Message "HDR enablement state is already $enablement for target $($this.FriendlyName), nothing to change" return $true }

and provide another boolean with a value for a Force option, or maybe even remove the if statment completely (or just the return statment). Not sure what would happen if the state is already enabled and you tried to enable it again, but might be worth a shot to do a quick test. Maybe I can do the test for you in the next few days

Hope this helps you debug this a bit more and get it fixed (even though its probably not the quickest or correct way to fix)!
debug_hdr
debug_hdr2

@spckayak
Copy link

spckayak commented Nov 21, 2024

I can confirm that by commenting out the true statement in the

"HDR enablement state is already $enablement for target $($this.FriendlyName), nothing to change "

function, it fixes the problem. For anyone else having this issue, this is how I solved it.

Navigate to where the module is installed, which by default is usually:

C:\Program Files\WindowsPowerShell\Modules\WindowsDisplayManager\

Using ethier Notepad++ or VSCODE, open the following file

C:\Program Files\WindowsPowerShell\Modules\WindowsDisplayManager\1.1.1\structures\Display.psm1

Then find the part of the code:

        if ($currentHdrInfo.HdrEnabled -eq $enablement) {
            Write-PSFMessage -Level Debug -Message "HDR enablement state is already $enablement for target $($this.FriendlyName), nothing to change"
            return $true

and change to

        if ($currentHdrInfo.HdrEnabled -eq $enablement) {
            Write-PSFMessage -Level Debug -Message "HDR enablement state is already $enablement for target $($this.FriendlyName), nothing to change"
          #  return $true

Then save. You might need to save the file to you Desktop Folder, then manually move it to this directory with Admin Permissions.

Last step, run this command in Windows Powershell:

Import-Module WindowsDisplayManager

That's It! This is a quick fix, as if you run "$primaryDisplay.DisableHdr()" it will still display as "True" even though it is "False"

What the "#" does above is forcing the code to execute anyway, even if it thinks HDR is already turned on and vice versa. I tested it on my computer, and it works flawlessly!

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

No branches or pull requests

3 participants