terrymacdonald / DisplayMagician

DisplayMagician is an open source tool for automatically configuring your displays and sound for a game or application from a single Windows Shortcut.
https://displaymagician.littlebitbig.com
GNU General Public License v3.0
444 stars 18 forks source link

DisplayMagician v2 game profile ported from DisplayMagician v1 does not work well #41

Closed domenic closed 2 years ago

domenic commented 3 years ago

Describe the bug

I have a game profile that does the following on launch:

and on shutdown it is supposed to:

This game profile was created in DisplayMagician v1, and when upgrading to DisplayMagician v2, I changed the display profile it was associated with, but did not recreate the entire thing.

To Reproduce / Expected behavior / Actual behavior

Clicking on the profile once changes the mode to surround but does not launch the external program or the game. It should do so.

Clicking on the profile again after the mode has already been set to surround will launch the external program and the game.

Once the game exits, the mode does not get changed back. It should be.

Once the game exits, I am not sure if the external program gets shut down or not. In my most recent session I shut down the external program manually mid-game. I will try to figure this out in future gaming sessions.

Reporting Logs

I did not create a trace-level log but can do so if it would be helpful. Here is the normal-level log: DisplayMagician.log

Here are my shortcuts and profiles JSON files, renamed to txt: Shortcuts_1.0.txt DisplayProfiles_2.0.txt

Enviroment (please complete the following information):

terrymacdonald commented 3 years ago

Hmm. That sounds like a possible race condition. I will need you to do a trace file, and then run through that same process that your described above to get the same errors. I need those trace messages in the log file to point me to the problematic code. Without those trace error messages in the log file it will be nearly impossible to fix this.

I'm very curious to know what bit is broken, because it sounds like it's in the display logic, but then a subsequent run of the same game shortcut does work. That shouldn't work! So lots more analysis to do.

Thanks Terry

domenic commented 3 years ago

I tried to create a trace log by changing the shortcut to have --trace at the end. I'm not sure it worked, but here is the result for the first run (that only changes to surround):

DisplayMagician.log

and here is the one for the second run (that launches the game and associated program):

DisplayMagician.log

If this did not properly put it into trace mode then please let me know exactly what command line I should use instead of

"C:\Program Files\DisplayMagician\DisplayMagician.exe" RunShortcut "90fc459c-c470-4dcf-a23d-164b403c9302" --trace
terrymacdonald commented 3 years ago

Thanks Domenic,

Unfortunately both DIsplayMagician.log files are missing most of the TRACE error messages. I can still glean some information from them, and it looks like the Display Profile isn't working as there is an error message from the WinLibrary.SetDisplayConfig saying that it couldn't validate the Windows config. This is the first time I've ever seen that!

2021-09-20 20:51:41.2218|ERROR|DisplayMagician.Program|WinLibrary/SetActiveConfig: ERROR - SetDisplayConfig couldn't validate the display configuration supplied. This display configuration wouldn't work.

Rather than add the --trace command line option, are you able to open DisplayMagician up, and go to Settings, and then set the logging level to 'Full application logs (large) or whatever its called? Then try to run the Game shortcut from the Shortcut Library window. That will do the same thing as the --trace option, and will generate the TRACE log entries in the DisplayMagician.log file. Then please upload the DisplayMagician.log file and I'll be able to see what part of the WinLibrary is having an error and why.

Thanks

Terry

On Tue, 21 Sept 2021 at 12:54, Domenic Denicola @.***> wrote:

I tried to create a trace log by changing the shortcut to have --trace at the end. I'm not sure it worked, but here is the result for the first run (that only changes to surround):

DisplayMagician.log https://github.com/terrymacdonald/DisplayMagician/files/7199400/DisplayMagician.log

and here is the one for the second run (that launches the game and associated program):

DisplayMagician.log https://github.com/terrymacdonald/DisplayMagician/files/7199404/DisplayMagician.log

If this did not properly put it into trace mode then please let me know exactly what command line I should use instead of

"C:\Program Files\DisplayMagician\DisplayMagician.exe" RunShortcut "90fc459c-c470-4dcf-a23d-164b403c9302" --trace

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-923488981, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LHGLHLIBVU2S45K243UC7JSRANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

terrymacdonald commented 3 years ago

OK - Did some more testing of this today, and there was a bug I introduced fairly recently that caused this specific issue :(. I've updated in the code, so this shouldn't happen again.

terrymacdonald commented 3 years ago

I'll close this issue as it will be fixed in the next release of DisplayMagician. Closing the issue helps me see what issues I have finished fixing and which ones I still have left to process. You can reopen this issue at any stage if you wish.

domenic commented 3 years ago

Great! Let me know when there's a new alpha to install and I can help confirm.

terrymacdonald commented 3 years ago

Great news! DisplayMagician v2.0.1 has been released, and it should fix this very issue. Please test it out, and if you still have any issues please log a new issue. You can get DisplayMagician v2.0.1 from here: https://github.com/terrymacdonald/DisplayMagician/releases/tag/v2.0.1

I'm closing this issue as the fix is in DisplayMagician v2.0.1, and I need to clear out the completed issues so I am able to work on the new issues that come in.

Thanks Terry

domenic commented 3 years ago

This issue is still occuring for me with DisplayMagician v2.0.1. Here is a trace log file from the first run (which only changes to surround):

DisplayMagician.log

and here it is from the second run (which starts the external program and the game): DisplayMagician.log

Here is the shortcuts file, renamed from .json to .txt:

Shortcuts_2.0.txt

terrymacdonald commented 3 years ago

@domenic I did find some issues with the profile detection that may have been contributing to this issue you reported. I've spent some time testing and it appears to be fixed for me on my test system, so I'm very keen to have you test this beofre I release it to the wider community.

DisplayMagicianSetup-v2.1.0.35-test.zip

One important thing to note - it will require you to create new Display Profiles as part of the upgrade. It turns out I needed a bit more information than was available in the DisplayProfiles_2.0.json format I created earlier. So this new 2.1 version creates a DisplayProfiles_2.1.json instead.

Hopefully everything works, and then I can release a new DisplayMagician version and move on to adding other features!

Thanks Terry

terrymacdonald commented 3 years ago

@domenic I'll leave this issue open for a week or two to wait to hear if this test version has fixed your problem. If I don't hear from you in the next week or two then I'll close the issue. Feel free to reop it after that time if you still have the issue even after installing DisplayMagician v2.1.0.

terrymacdonald commented 3 years ago

@domenic Please install this new build, and see if it's fixed the issue you had in the past.

DisplayMagicianSetup-v2.1.0.79.zip

Thanks Terry

domenic commented 3 years ago

Unfortunately it has not. The shortcut still only changes the mode on first launch and requires clicking it a second time to launch the external program and the game.

terrymacdonald commented 3 years ago

Hi Domenic,

It looks like your DisplayProfiles might be the older format. Can you please try the following with DisplayMagician v2.1.0.79:

Depending on the errors we get, I may need to get you to test the nvidia video library with the NVIDIAInfo test program I've made. It will make it easier to test and figure out what the issue is.

Thanks

Terry

On Wed, 3 Nov 2021 at 16:18, Domenic Denicola @.***> wrote:

Unfortunately it has not. The shortcut still only changes the mode on first launch and requires clicking it a second time to launch the external program and the game.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-958626989, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LAV5JK2FEOAQ4NCZ6LUKCZYZANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

domenic commented 3 years ago

The profiles seem to be in the latest format to me: that is, the DisplayProfiles_2.1.txt I posted above has the new ColorConfig section, whereas my DisplayProfiles_2.0.json does not have that section.

When I recreate the profiles from scratch, I get the same JSON as my above DisplayProfiles_2.1.txt (except for the UUIDs).

I have confirmed I am running DisplayMagician v2.1.079 (according to the version number in the lower left on the main DisplayMagician screen).

So if there is supposed to be extra data in my profiles, or some newer format, I think DisplayMagician is not writing that data out to the DisplayProfiles_2.1.json file.

terrymacdonald commented 3 years ago

@domenic, what step did you get in the list that I sent through? I need you to perform those tests in the order that I listed them, as that will help me understand what bits are breaking.

The list of steps I need you to follow:

I've just created a new test version (v2.1.0.160) and the changes I've made might help, so please install it over the top of your last install, and then try the list of tasks again.

DisplayMagicianSetup-v2.1.0.160.zip

I'm not that confident that this latest version will fix your underlying problem, but that list of tests will at least hopefully provide some extra information about what's occurring.

Thanks Terry

domenic commented 3 years ago

I did all those steps. The result was the same as before, as you might expect from the profile JSON files being the same as before.

I will try the new version this weekend!

terrymacdonald commented 3 years ago

Sorry to be overly specific, but I really need to understand the exact point you got up to, so that I can understand what stage DisplayMagician might be failing. Based on your comments you got here:

And then it didn't work after that point (as before). Is that correct?

I think we need to move to NVIDIAInfo testing in order to progress this. Are you happy to do some more testing with NVIDIAInfo?

If so, please download the latest version of NVIDIAInfo from https://github.com/terrymacdonald/NVIDIAInfo/releases and please make the same two profiles that you're having issues with. Then please attempt to perform the swap that is causing the errors.

That should generate an NVIDIA.log. Please upload that and the two .cfg files you used, and it should hopefully give me some more information for me to test.

Thanks Terry

domenic commented 3 years ago

It worked past that point. I rebooted and it worked after reboot. And I recreated my shortcuts using the new profiles. After that I went to the last step, to test the game shortcut. The game shortcut had the same behavior as before, of only changing the profile and not launching the game on the first click.

Happy to test with NVIDIAInfo. However I'm a bit surprised that it's at the NVIDIA level; given that the profile switching part of the shortcut works fine, and it's just the game-launching part that fails, I was hoping the fix would be in the game-launching logic.

terrymacdonald commented 2 years ago

Excellent, that clears things up a bit. I was under the impression that it was a display profile problem, hence my focus in that area. I'm not sure how I got that impression, but there you go! Glad we got that cleared up.

Are you having problems with all games, or just with Star wars old republic?

Also, can you create another Star wars old republic shortcut but don't add a start program. Then please test that. I want to know if the fault is being caused by start programs or not.

Also, can you please provide me a link to the friend location for starparse.exe? I think it could be something with starting starparse.exe which is faulting, and causing the rest of the shortcut processing to be ignored.

Can you please test with the latest test version that I just dropped here: DisplayMagicianSetup-v2.1.0.160.zip

And then report back with what you find please. Really sorry about the mix up!

[EDIT] I just saw in scrollback that you already tested this version. It must still be an issue, so I'll do some testing myself as soon as I find out what startparse.exe is

[EDIT2] Found it. Amazingly I also have SWTOR in my game collection so I'm installing it now so I can test with exactly the same game setup as you have. I should then be able to debug live on my machine and hopefully find the cause of the issue.

Thanks Terry

terrymacdonald commented 2 years ago

@domenic OK - Now that I understand the problem, I've developed a fix for the issue. Turns out starparse.exe is a Java application that has a launcher. The launcher starts, then loads the java code as a child process, and then exits the original process. That completely broke DisplayMagician's process starting logic.

I had to completely rewrite the ProcessUtils library from scratch :(. I've now got a version of DisplayMagician that I think is pretty robust. I've been able to find some amazing example code that I've tweaked, modified and extended to completely rebuild the process starting library. The new process library does a few cool things:

I'm pretty darn happy with the code that came out of the rewrite process now, and I feel like your help pointing out all the broken bits really helped pull DisplayMagician forwards. It feels like it's nearly ready to ship (though I might need some more tweaks to support NVIDIA Display Config extraction...that's another story).

Note: I tested this with SWTOR and Starparse.exe and it worked on my machine, even handling the child processes and even closing it down after I exited SWTOR! So I'm pretty happy.

Anyway, can you please test this latest version, and see if there is anything that doesn't work. I'd love to get all the issues fixed if I can before release :D.

DisplayMagicianSetup-v2.1.0.197.zip

Thanks Terry

domenic commented 2 years ago

Wow, thank you for all that investigative work! I was really excited to see all that you'd done. Unfortunately, I'm still having issues...

Using DisplayMagician 2.1.0.197, I deleted everything, and created new display profiles from scratch. Then I created a game shortcut for SWTOR with no pre-run program (i.e. no StarParse).

Unfortunately, the game shortcut still only changes the display profile, and doesn't launch the program. Probably it is related to these lines from the log?

2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/UpdateActiveProfile: The NVIDIA profile 'Surround' is currently active (in use now).
2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/ApplyProfile: Display change attempt took 0:6.279 and was successful.
2021-11-07 12:52:23.1521|ERROR|DisplayMagician.ShortcutRepository|ShortcutRepository/RunShortcut: Cannot apply 'Surround' Display Profile
2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|Beginning to shutdown

i.e. for some reason it seems to have successfuly gotten into the "Surround" mode, but then it thinks it failed and so stops the shortcut process. If I understand correctly.

I created a second shortcut that tries to launch another game (Splitgate) which has the same issue.

I've also encountered some other bugs which are troubling:

I wish I had better news! :(

terrymacdonald commented 2 years ago

Darn. That's annoying.

Ok, the display thing is something I'll have to look into in more depth. It may be something related to the changes I made to support the future storage of custom displays and NVIDIA display config. I'll have to do some more testing.

The double up of games listed on the shortcut form is confusing. That may be related to the image parsing screen hanging and you cancelling it.

In this new version of DisplayMagician, I've split the image processing in half. The reason for this to try and speed up the UI for how people use it most. The images for games only need to be parsed just before opening the shortcut editing form, as that's the only time they're needed. So that pop-up 'parsing images' screen is really important, as it is processing the games images.

It shouldn't take 10 mins though even if you have hundreds of games installed, so that tells me that is getting stuck somewhere while it's processing the images. That's a definite bug that needs to be sorted.

How many games do you have installed in each game library? Steam, Uplay, Epic, Origin and Galaxy of gamers (GOG)? If you can tell me which game libraries you don't have installed then that may help me figure out where the bug lives.

Also, can you please try and go into the new game shortcut, and let the image parsing screen show, and then save a copy of the DisplayMagician.log? It should show at the bottom of the log where it has gotten stuck, and that again will help me troubleshoot.

Thanks you so much for continuing to help me out when this has taken so long to fix! I really do appreciate it, and will get it sorted eventually.

Thanks Terry

On Mon, 8 Nov 2021, 07:00 Domenic Denicola, @.***> wrote:

Wow, thank you for all that investigative work! I was really excited to see all that you'd done. Unfortunately, I'm still having issues...

Using DisplayMagician 2.1.0.197, I deleted everything, and created new display profiles from scratch. Then I created a game shortcut for SWTOR with no pre-run program (i.e. no StarParse).

Unfortunately, the game shortcut still only changes the display profile, and doesn't launch the program. Probably it is related to these lines from the log?

2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/UpdateActiveProfile: The NVIDIA profile 'Surround' is currently active (in use now). 2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/ApplyProfile: Display change attempt took 0:6.279 and was successful. 2021-11-07 12:52:23.1521|ERROR|DisplayMagician.ShortcutRepository|ShortcutRepository/RunShortcut: Cannot apply 'Surround' Display Profile 2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|Beginning to shutdown

i.e. for some reason it seems to have successfuly gotten into the "Surround" mode, but then it thinks it failed and so stops the shortcut process. If I understand correctly.

I created a second shortcut that tries to launch another game (Splitgate) which has the same issue.

I've also encountered some other bugs which are troubling:

  • All my Steam games are listed twice when creating or editing a game shortcut.
  • I've several times gotten a screen "Preparing images..." which hangs forever. (Or at least, for longer than 10 minutes.) I have to "End task" on DisplayMagician from the task manager to make it stop.
    • The first time was when I was trying to edit the SWTOR shortcut
    • The second time was when I was trying to launch the SWTOR shortcut from my desktop
    • The third time was when I launched the Splitgate test game shortcut

I wish I had better news! :(

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-962654816, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LGI5I27QLBKGGCDVETUK25EDANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

terrymacdonald commented 2 years ago

Oh, I almost forgot. As a test, could you please try changing the display profile on that surround shortcut that fails to run, to another different profile that doesn't use NVIDIA surround. Then try to run it after you've made the change.

This will test of that particular display profile is causing the error, or if something else in that game shortcut is.

If the game shortcut then starts working, we know it's display profile related.

If the game shortcut still doesn't work then we know it's game shortcut related.

Thanks Terry

On Mon, 8 Nov 2021, 07:00 Domenic Denicola, @.***> wrote:

Wow, thank you for all that investigative work! I was really excited to see all that you'd done. Unfortunately, I'm still having issues...

Using DisplayMagician 2.1.0.197, I deleted everything, and created new display profiles from scratch. Then I created a game shortcut for SWTOR with no pre-run program (i.e. no StarParse).

Unfortunately, the game shortcut still only changes the display profile, and doesn't launch the program. Probably it is related to these lines from the log?

2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/UpdateActiveProfile: The NVIDIA profile 'Surround' is currently active (in use now). 2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|ProfileRepository/ApplyProfile: Display change attempt took 0:6.279 and was successful. 2021-11-07 12:52:23.1521|ERROR|DisplayMagician.ShortcutRepository|ShortcutRepository/RunShortcut: Cannot apply 'Surround' Display Profile 2021-11-07 12:52:23.1521|DEBUG|DisplayMagician.Program|Beginning to shutdown

i.e. for some reason it seems to have successfuly gotten into the "Surround" mode, but then it thinks it failed and so stops the shortcut process. If I understand correctly.

I created a second shortcut that tries to launch another game (Splitgate) which has the same issue.

I've also encountered some other bugs which are troubling:

  • All my Steam games are listed twice when creating or editing a game shortcut.
  • I've several times gotten a screen "Preparing images..." which hangs forever. (Or at least, for longer than 10 minutes.) I have to "End task" on DisplayMagician from the task manager to make it stop.
    • The first time was when I was trying to edit the SWTOR shortcut
    • The second time was when I was trying to launch the SWTOR shortcut from my desktop
    • The third time was when I launched the Splitgate test game shortcut

I wish I had better news! :(

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-962654816, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LGI5I27QLBKGGCDVETUK25EDANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

domenic commented 2 years ago

How many games do you have installed in each game library? Steam, Uplay, Epic, Origin and Galaxy of gamers (GOG)? If you can tell me which game libraries you don't have installed then that may help me figure out where the bug lives.

Just Steam (although I guess Origin is installed by Steam in the background to run some games like Mass Effect)? A total of 12 games installed right now (so, 24 games showing in DisplayMagician). Here is a screenshot in case it helps:

image image

Also, can you please try and go into the new game shortcut, and let the image parsing screen show, and then save a copy of the DisplayMagician.log? It should show at the bottom of the log where it has gotten stuck, and that again will help me troubleshoot.

Here is a log. It actually allows me to create the new shortcut, and the "Preparing images..." screen is just stuck in a background window.

DisplayMagician.log

Oh, I almost forgot. As a test, could you please try changing the display profile on that surround shortcut that fails to run, to another different profile that doesn't use NVIDIA surround. Then try to run it after you've made the change.

That works! I used my "Work" profile (2 monitors enabled, 1 disabled, no surround) and it launched SWTOR.

terrymacdonald commented 2 years ago

Good stuff, we're at least getting somewhere.

The steam parsing l didn't have enough logging around, so I've added some additional error checking, so I've temporarily added a 'contains' check to the steam library to make sure it only adds things that aren't already added. Can you please test this build to see if the doubled Steam icons disappear?

DisplayMagicianSetup-v2.1.0.199.zip

As for the surround profile, this is where the error lies:

2021-11-07 12:58:55.5022|ERROR|DisplayMagician.Program|WinLibrary/SetActiveConfig: ERROR - SetDisplayConfig couldn't validate the display configuration supplied. This display configuration won't work if applied.
2021-11-07 12:58:55.5022|TRACE|DisplayMagician.Program|ProfileRepository/SetActive: The Windows CCD display settings within profile Surround were NOT applied correctly.
2021-11-07 12:58:55.5022|ERROR|DisplayMagician.Program|ProfileRepository/ApplyProfile: Error applying the NVIDIA Profile!

The issue appears to be that the Windows part of the surround profile can't be applied. This is what happens when a profile is applied:

That error message means that it is stopping on step 2 above (Windows display layout arrangement),

So, as a test, can you please create a brand new Surround profile. Please wait while you make it until no more screen changes are happening, and all the screens are in their final layouts. Then save that new surround profile as a new display profile. And then use that profile with that same SWTOR game shortcut you used before.

What I'm hoping to see is whether a newly created surround profile works. It could be that there is a bug that only happens some times when creating surround profiles, and doesn't happen other times. I'm trying to see if that is what is happening here. If it still happens with a new surround profile, then we know its something else.

Please report back with the DisplayMagician.log and the DisplayProfiles_2.1.json as I want to see what's different between the two display profiles.

Thanks Terry

terrymacdonald commented 2 years ago

To be honest, I think we're going to need to do some testing with NVIDIAInfo to eliminate the surround profile issue. I'll have a think about it during the day while I'm at work and see what I can come up with later tonight.

What's your availability like over the next few days/week?

Thanks Terry

domenic commented 2 years ago

So, as a test, can you please create a brand new Surround profile. Please wait while you make it until no more screen changes are happening, and all the screens are in their final layouts. Then save that new surround profile as a new display profile. And then use that profile with that same SWTOR game shortcut you used before.

I'm unsure how best to follow these instructions. How I normally create the Surround profile is the following:

  1. Open NVIDIA Control Panel
  2. Go to "Configure Surround, PhysX"
  3. Click "Configure..."
  4. This always shows my displays as 3/1/2, whereas they are physically arranged as 2/1/3. So I drag display 3 over to the right.
  5. I change the Refresh Rate dropdown from 120 Hz to 98 Hz. (98 Hz is necessary for HDR to continue working.)
  6. I click "Enable Surround"
  7. I completely exit NVIDIA Control Panel.
  8. I go to DisplayMagician and create a new profile.

Note that when I try do this again DisplayMagician says "Surround: This is the Display Profile currently in use" and will not let me create a new one. Presumably I'd have to delete the old one first.

After deleting it, closing the dialog, reopening it, and pressing "Save As", I get the following:

If there is a different sequence of instructions for creating a profile that might have a better chance of working, let me know.

What's your availability like over the next few days/week?

In general I'm available after work hours (Eastern US time) most days.

terrymacdonald commented 2 years ago

@domenic sorry for the poor instructions :(. What I meant was:

If everything works ok, and the game runs, then that means that the previous display profile had an issue. If everything still is broken and the surround profile gets applied but the RunShortcut function exits straight after applying the profile without running anything, then that means we've got some video library testing to do :).

Thanks Terry

domenic commented 2 years ago

The game does not run. DisplayMagician-Support-20211108-1824.zip

Ready for some video library testing!

terrymacdonald commented 2 years ago

Yep. I think the same. It's time to do that for sure.

One small problem, I'm part way through an update of the NVIDIAInfo software NVIDIALibrary to include CustomDisplays and DisplayConfigs to handle some of the more advanced NVIDIA features. I'll have to get NVIDIAInfo to a stage that it works again, so please give me a few days to sort it out.

I'll get back to you after I've got it running on my test system, and I'll include a list of tests that we will do in a special order so that I can figure out where the error lies. I need to run some more tests myself first so I can get rid of as many bugs as I can before I get you to do any further work :).

Thanks Terry

terrymacdonald commented 2 years ago

Ok @domenic,

I got NVIDIAInfo into a state we can test with. I've tested it on my own system and it works with cloned windows, extended windows, and NVIDIA surround windows. I've tried after multiple reboots, and I can swap between all 3 types of configurations perfectly fine.

So, now it's time to try it on your system.

Can you please download NVIDIAInfo v1.2.3 zip file from https://github.com/terrymacdonald/NVIDIAInfo/releases/tag/v1.2.3 and unzip it somewhere on your computer. Then please print out the following instructions, and follow them exactly, recording what happened after each command. This is REALLY important as the order I've given these commands is exact, and they need to be run in exactly the order they are listed.

If you get any errors, please immediately save the NVIDIAInfo.log file and rename the copy to a name that will indicate what the error is for e.g. NVIDIAInfo-work-to-normal-first-time.log. Then I'll know exactly what the log file is for.

If all that testing above works without any errors, then we want to start testing the NVIDIA Surround configuration part of the code. To do that, follow these instructions:

If we get to this point, then we're really humming along :). Next test, is to change out of surround mode, and see if the other configs still work.

And if we reach this point, then we've tested that we can change to surround and back again and still have the equality testing working fine as well.

This test group of tests is to make sure that we can go back into surround without any errors.

And then as a final double check, we want to go back to the work config:

If we get here, then we're almost done. We've proved that we can swap freely between 3 different configurations so far with the testing above, but we've not checked if those configurations stay valid after a reboot. Windows changes display IDs and a whole lot of other bits of the config that I have to patch and tweak as part of the saving process. This is what I need you to test next:

This test group of tests is to make sure that we can go back into surround without any errors, even after a reboot.

And then as a final double check, we want to go back to the work config, proving this works after a reboot:

If we get here, then we're done for now! This means all the bits you need are working.

If we get to the end of all these tests and they all work, then I'll get you to do some more tests for me for cloned displays. I didn't want to complicate matters right now, so we'll test those once we get your three configs working well.

Once the tests are finished, please upload the results of each individual test (one per bullet point), and please include multiple the NVIDIAInfo log files you saved earlier when you found errors. Please also include the 3 cfg files so that I can compare them all. And if there are any error-.cfg files you save, then please upload those as well.

That should be enough for me to fully understand what's happening with your displays :)

Really sorry its so much work, but these are exactly the step-by-step tests I do on my machine when I'm troubleshooting :D.

Thanks Terry

domenic commented 2 years ago

First block of instructions gave an error at NVIDIAInfo.exe load normal.cfg, with the attached log and the following stack trace:

$ ./NVIDIAInfo.exe load normal.cfg

NVIDIAInfo v1.2.3
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from normal.cfg

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at DisplayMagicianShared.NVIDIA.NVIDIALibrary.SetActiveConfigOverride(NVIDIA_DISPLAY_CONFIG displayConfig) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\NVIDIALibrary.cs:line 1565
   at NVIDIAInfo.Program.loadFromFile(String filename) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\Program.cs:line 345
   at NVIDIAInfo.Program.Main(String[] args) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\Program.cs:line 116

However, the display configuration did seem to change to normal, and NVIDIAInfo.exe equal normal.cfg told me they were equal when I ran it immediately after. Also as hoped, NVIDIAInfo.exe equal work.cfg said they were NOT equal.

I'm unsure whether to proceed with the next block of instructions. Let me know if I should, or if you want to try to straighten out that KeyNotFoundException first!

terrymacdonald commented 2 years ago

I'll fix that error first, then I'll get you to start the instructions again with a new version of NVIDIAInfo.

Thanks Terry

On Thu, 11 Nov 2021, 14:47 Domenic Denicola, @.***> wrote:

First block of instructions gave an error at NVIDIAInfo.exe load normal.cfg, with the attached log and the following stack trace:

$ ./NVIDIAInfo.exe load normal.cfg

NVIDIAInfo v1.2.3

By Terry MacDonald 2021

Attempting to apply NVIDIA display config from normal.cfg

Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at DisplayMagicianShared.NVIDIA.NVIDIALibrary.SetActiveConfigOverride(NVIDIA_DISPLAY_CONFIG displayConfig) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\NVIDIALibrary.cs:line 1565 at NVIDIAInfo.Program.loadFromFile(String filename) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\Program.cs:line 345 at NVIDIAInfo.Program.Main(String[] args) in H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\Program.cs:line 116

However, the display configuration did seem to change to normal, and NVIDIAInfo.exe equal normal.cfg told me they were equal when I ran it immediately after. Also as hoped, NVIDIAInfo.exe equal work.cfg said they were NOT equal.

I'm unsure whether to proceed with the next block of instructions. Let me know if I should, or if you want to try to straighten out that KeyNotFoundException first!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-965917384, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LANVSMT45QRV33K3GLULMOBTANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

terrymacdonald commented 2 years ago

@domenic Well delving into that latest error is weird. The code shouldn't be having an error in that place (which is where its trying to load ColorData after it's done the surround, and after windows has set things up, and NVIDIA then tries to set color as the last thing).

The error says that the key's aren't in the dictionary, but I know they are as I can see them in your config! So there may be a couple of things going on here. 1. Your video card may not be returning the right data when queried...but thats unlikely. 2. There is an odd serialisation error with the way that the JSON CFG files are written to disk... I've made changes in NVIDIAInfo v1.2.3b assuming this is the problem. 3. Something else I've not thought of yet.

I have tweaked the code assuming it's #2 in that list, so please go ahead and try to do the first section of tests. You can reuse the same cfg files to start with. If you get the same error as the last one you reported, please delete the cfg files and then try again.

Thanks Terry

terrymacdonald commented 2 years ago

oh forgot to post the new code :). Please run this NVIDIAInfo for the tests: NVIDIAInfo-v1.2.3b.zip

domenic commented 2 years ago

Same issue, even with fresh profiles.

I managed to boot up the invocation in Visual Studio and noted the failure is in this line, if it helps (decompiled code, so the variable names are presumably wrong):

foreach (KeyValuePair<string, NV_COLOR_DATA_V5> colorDataDict2 in displayConfig.ColorConfig.ColorData)
{
  NV_COLOR_DATA_V5 colorData2 = colorDataDict2.Value;
  string displayId2 = colorDataDict2.Key;
  uint displayIdAsUInt33 = uint.Parse(displayId2);
  if (colorData2.ColorSelectionPolicy != NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_BEST_QUALITY && ActiveDisplayConfig.ColorConfig.ColorData[displayId2].ColorSelectionPolicy != colorData2.ColorSelectionPolicy) // HERE
  {

Indeed, displayId2 is "2147881091", but ActiveDisplayConfig.ColorConfig.ColorData does not contain that key: it contains the two keys "2147881088" and "2147881093".

Starting to speculate here: in the work configuration, my right display is turned off, i.e. only two displays are turned on. Whereas in the normal configuration all three are turned on. Maybe "2147881091" is the rightmost display ID, but ActiveDisplayConfig.ColorConfig.ColorData only contains the left and middle display.

terrymacdonald commented 2 years ago

Wow awesome work. I think you could be correct. I'll add a try around that area to catch the exception.

Those are the exact commands btw, as I include the pdb files in the zip file so this sort of thing is possible. But this is the first time ever someone had done this! It's great!

I'll go as the code in a couple of hours, and send it through.

Perfect troubleshooting 👍

Thanks Terry

On Fri, 12 Nov 2021, 18:33 Domenic Denicola, @.***> wrote:

Same issue, even with fresh profiles.

I managed to boot up the invocation in Visual Studio and noted the failure is in this line, if it helps (decompiled code, so the variable names are presumably wrong):

foreach (KeyValuePair<string, NV_COLOR_DATA_V5> colorDataDict2 in displayConfig.ColorConfig.ColorData) { NV_COLOR_DATA_V5 colorData2 = colorDataDict2.Value; string displayId2 = colorDataDict2.Key; uint displayIdAsUInt33 = uint.Parse(displayId2); if (colorData2.ColorSelectionPolicy != NV_COLOR_SELECTION_POLICY.NV_COLOR_SELECTION_POLICY_BEST_QUALITY && ActiveDisplayConfig.ColorConfig.ColorData[displayId2].ColorSelectionPolicy != colorData2.ColorSelectionPolicy) // HERE {

Indeed, displayId2 is "2147881091", but ActiveDisplayConfig.ColorConfig.ColorData does not contain that key: it contains the two keys "2147881088" and "2147881093".

Starting to speculate here: in the work configuration, my right display is turned off, i.e. only two displays are turned on. Whereas in the normal configuration all three are turned on. Maybe "2147881091" is the rightmost display ID, but ActiveDisplayConfig.ColorConfig.ColorData only contains the left and middle display.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/41#issuecomment-966833110, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LCIY4IU5EVXFWES3CTULSRJ3ANCNFSM5EDZ3ECQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

terrymacdonald commented 2 years ago

Hi @domenic,

So I decided to add a check first rather than cause the exception, so now the situation that is causing the crash is being bypassed. Hopefully that works!

Please give it another shot with NVIDIA v1.2.3c: NVIDIAInfo-v1.2.3c.zip

This is good stuff. I wouldn't have found that config problem without your doing what you did! 👍

Thanks Terry

domenic commented 2 years ago

Alright, got much further this time! To

This test group of tests is to make sure that we can go back into surround without any errors.

  • Next, run NVIDIAInfo.exe load surround.cfg which will try to change the display layout to the Surround configuration. We want NVIDIAInfo to change to the surround layout with no errors.

which gives

$ ./NVIDIAInfo.exe load surround.cfg

NVIDIAInfo v1.2.3c
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from surround.cfg
ERROR - NVIDIAInfo Windows CCD settings were not applied correctly.

with the following logs and configs:

Note however that I did end up in surround mode after running the command.

domenic commented 2 years ago

Oh, I also ran NVIDIAInfo.exe equal surround.cfg after loading the surround config, and it said they were equal!

$ ./NVIDIAInfo.exe equal surround.cfg

NVIDIAInfo v1.2.3c
=================
By Terry MacDonald 2021

The NVIDIA display settings in surround.cfg and the currently active display configuration are equal.
terrymacdonald commented 2 years ago

@domenic was that surround.cfg.txt you uploaded the original one you created? Or is it the equivalent of the error-surround2.cfg config I mentioned here:

Next, run NVIDIAInfo.exe equal surround.cfg which will check to see if NVIDIAInfo thinks the config we just saved is the same as the current display. We want NVIDIAInfo to say they are equal. If it says they are not equal, please run NVIDIAInfo.exe save error-surround2.cfg

The error-surround2.cfg file would let me see what's different between the original surround.cfg and the current display config (error-surround2.cfg). This lets me figure out if there is a problem with equality matching, or just with a particular function that's applying some config changes.

If you're still on the surround display config then could you please generate the error-surround2.cfg file (only if you haven't already) and send that through. I'll do some comparison and see what I can find.

Thanks! Terry

domenic commented 2 years ago

It was the original one I created. Note that NVIDIAInfo says that they are equal, so I don't think the step you're discussing applies.

terrymacdonald commented 2 years ago

@domenic it might. That equality testing is based on my custom equality testing logic, and its that part which I'd like to confirm. Those instructions I've given you are extremely specific because I want to doublecheck my work at each step. I need to confirm it is the same, and for that I need the information from you. At each step I need to be sure it is right so I can discount that as a potential flaw. It may be that a certain step works for you, but it is actually wrong in the equality code, and that is something I'll be potentially able to see if you send me the configs in the order I need them.

I'm really keen to iron out some of these logic flaws so that we fix problems for everyone, and you're currently the best person to enable this to happen. With your help I might be able to get the NVIDIALibrary finally fully ironed out of bugs.

So, if you're still in the same surround profile, it would be really helpful if you could send me the error-surround.cfg that you generate using NVIDIAInfo.exe save error-surround2.cfg. I'll then do a compare and see what differences there are between the one we asked NVIDIAInfo to set, and the one we actually got.

Thanks Terry

domenic commented 2 years ago

I'm currently back in the normal profile. So I'll try going back to the work profile, then to surround, and then saving the result again?

domenic commented 2 years ago
Domenic@Domenic-Desktop MSYS ~/Downloads/NVIDIAInfo-v1.2.3
$ ./NVIDIAInfo.exe load work.cfg

NVIDIAInfo v1.2.3c
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from work.cfg
NVIDIAInfo Display config successfully applied

Domenic@Domenic-Desktop MSYS ~/Downloads/NVIDIAInfo-v1.2.3
$ ./NVIDIAInfo.exe load surround.cfg

NVIDIAInfo v1.2.3c
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from surround.cfg
ERROR - NVIDIAInfo Windows CCD settings were not applied correctly.

Domenic@Domenic-Desktop MSYS ~/Downloads/NVIDIAInfo-v1.2.3
$ ./NVIDIAInfo.exe save error-surround2.cfg

NVIDIAInfo v1.2.3c
=================
By Terry MacDonald 2021

Display settings successfully saved to error-surround2.cfg.

error-surround2.cfg.txt

terrymacdonald commented 2 years ago

Also, just to let you know I'm part way through a new version v1.2.4 which has some additional logging to find out what exactly Windows CCD SetDisplayConfig doesn't like about the config it's getting. Hopefully that will shed some more light on the problem. I'm trying to figure out what it hates.

In this version I've also moved where the prior color settings are removed until before the mosaic/surround screen changes, as that's where they should logically sit. This also should avoid the 'missing' dictionary keys completely, as they will still be there at this point. 🤞.

New build within the next hour or so.

terrymacdonald commented 2 years ago

@domenic I think we're getting somewhere. I have high hopes for this set of tests.....

So a summary of what I've found:

The Windows CCD display config validation function doesn't actually validate in the way we need it to :). What this means is that it is saying a display config is invalid, when it is valid with the right combination of flags. So I've disabled validation in this version, and the code will just have to handle any failures after we've tried to apply the setting. I figure that as the setting is retrieved directly from a valid, working Windows CCD Display layout anyway, then this shouldn't matter. Windows should always provide us with a valid display config, so no real need to check for a valid config in my code!

The new changed colour settings code location is working well, with no skipped screens. It's in the correct logical place now.

The Windows CCD SetDisplayConfig now logs as much information as we can from the API as to what the failure is if it cannot apply it. This should help me when troubleshooting.

Thanks for the error-surround.cfg file too. I compared that to the previous surround.cfg file and it only changes in windows adapter IDs, which is perfect! It confirms to me that the WinLibrary display config generation is working, that the WinLibrary display ID patching is working, and that the existing equality testing will work fine. 👍

So, here is a brand new NVIDIAInfo v1.2.4, and 🤞 it works! Please restart the testing, and here's hoping we get to the end without any more problems.

NVIDIAInfo-v1.2.4.zip

Thanks Terry

domenic commented 2 years ago

Fascinating, this time I got a problem at this step:

Next, run NVIDIAInfo.exe equal normal.cfg which will check to see if NVIDIAInfo thinks the config we just saved is the same as the current display. We want NVIDIAInfo to say they are equal.If it says they are not equal, please run NVIDIAInfo.exe save error-normal2.cfg

configs-and-log.zip

I really appreciate your persistence!

terrymacdonald commented 2 years ago

Ohhhhhhh! This one is juicy. A couple of things for me to investigate. One question first - are you on Windows 11 at the moment or still on Win 10? Just want to know for future reference.

When coming back from the surround to the normal config, Windows CCD reports the items in a completely different order! This also happens in the GDI settings as well. I'll have to check whether the equality testing actually handles that situation. My gut feel is that it doesn't, and that I'll need to write a custom equality test that doesn't break when things are in different order in a dictionary and will swap to using that.

I've also noticed an issue with your NVIDIA colour config that doesn't happen with mine. As you can see from this screenshot, your HDR settings are different when changing back...

image

I wonder whether some of the past config changes have every so slightly changed the config, making them different enough that they don't match? This would impact all our testing from now on, so we're going to need to start again from the complete NVIDIAInfo beginning, and remove all the existing cfg files to start again just to make sure all the configs match the real settings again.

So, can you please delete all the .cfg's you have, and start again completely from scratch, e.g. recreate the display configs again and then go through the instructions step by step, and then we'll see if we get the same problem you got this time. If we do get the same problem then that's excellent because we know that the error is repeatable, which means we'll know when I fix it. And if we don't get the same error, then that's also excellent because we know it was an issue with reusing the old configs! (Does that make sense?)

Finally if there's one thing people can say about me , it's that I'm persistent ;P. I've spent nearly 9 months developing my own custom video libraries to support 3 different groups of video cards, so I'm definitely going to keep going until we finally get these bugs sorted! We're soooo close!

Thank you for all the time you're spending doing these tests. I know how monotonous they are, but they really are key to enable me to squash those bugs. Just imagine yourself at the end of this process just clicking on a single desktop shortcut to have all the magic happen :).

Thanks Terry

terrymacdonald commented 2 years ago

OK, Further testing has shown that the equality tests fail for the first profile after returning from a surround profile to a non-surround profile. If that profile is applied again, then the equality tests start working again! This is shown in the following output:

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

Display settings successfully saved to .\test-surround-only.cfg.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe load .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from .\test-triple-left.cfg
NVIDIAInfo Display config successfully applied

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-triple-left.cfg and the currently active display configuration are equal.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-triple-middle.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-triple-middle.cfg and the currently active display configuration are NOT equal.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe load .\test-surround-only.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from .\test-surround-only.cfg
NVIDIAInfo Display config successfully applied

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-triple-left.cfg and the currently active display configuration are NOT equal.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-surround-only.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-surround-only.cfg and the currently active display configuration are equal.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe load .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from .\test-triple-left.cfg
NVIDIAInfo Display config successfully applied

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-triple-left.cfg and the currently active display configuration are NOT equal.

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe load .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

Attempting to apply NVIDIA display config from .\test-triple-left.cfg
NVIDIAInfo Display config successfully applied

PS H:\vscode-projects\NVIDIAInfo\NVIDIAInfo\bin\Debug> .\NVIDIAInfo.exe equal .\test-triple-left.cfg

NVIDIAInfo v1.2.4
=================
By Terry MacDonald 2021

The NVIDIA display settings in .\test-triple-left.cfg and the currently active display configuration are equal.

Now that this is reproducible repetitively, I should be able to figure out a work around! I'm going to save some cfg files between the responses to see what the differences are.

@domenic you don't need to do that last bit of testing any longer as I've been able to trigger the bug myself. I can now test myself if it's fixed :). When I have squashed the bug here, I'll get you to test again to make sure it's fixed for good.

Again, thanks for all your help. Terry