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

Superdisplay Profile Not Loading After System Reboot #103

Open
cerahmed opened this issue May 6, 2022 · 73 comments
Open

Superdisplay Profile Not Loading After System Reboot #103

cerahmed opened this issue May 6, 2022 · 73 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cerahmed
Copy link

cerahmed commented May 6, 2022

Describe the bug
This would be a continuation for issue#96 regarding Superdisplay profile not loading correctly, however this time with new symptoms.

So I'm currently using version 2.3.1.28 found in this comment. Everything was working perfectly and I was able to switch to every Superdisplay profile without issues.

However, seemingly after restarting my pc and reconnecting my Superdisplay tablet, switching to the Superdisplay (both Extended and Duplicated) profiles seems to disable all USB monitors.

To Reproduce
I haven't yet confirmed if it happens after every reboot, but I'll do so if the issue can't be figured out from the log file.

Screenshots
Configs-Changed

DisplayMagician-Support-20220506-1444.zip

@cerahmed cerahmed added the bug Something isn't working label May 6, 2022
@terrymacdonald
Copy link
Owner

terrymacdonald commented May 6, 2022 via email

@cerahmed
Copy link
Author

cerahmed commented May 7, 2022

Hi Terry,

I updated to v2.3.1.60, but it crashes right after showing the initialization dialog.
I created a trace log and also attached the relevant files for your review.

DisplayMagician.log
Profiles, Shortcuts, and Settings.zip

@cerahmed
Copy link
Author

cerahmed commented May 7, 2022

I went ahead and deleted DisplayMagician folder inside AppData/Local, and it worked just fine.
I'll start testing for the symptoms I described in this post and will get back with my results.

@terrymacdonald
Copy link
Owner

terrymacdonald commented May 7, 2022 via email

@cerahmed
Copy link
Author

cerahmed commented May 7, 2022

Hi again Terry,

So I was able to reproduce the issue:

  1. I upgraded to the latest version 2.3.1.60.
  2. Saved new profiles.
  3. Switching between profiles works fine.
  4. Restarted my PC.
  5. Connected SuperDisplay.
  6. Tried switching to the Extended profile.
  7. Both USB monitors become disabled.
  8. Saved logs and attached.

DisplayMagician-Support-20220507-0951.zip

@terrymacdonald
Copy link
Owner

terrymacdonald commented May 7, 2022 via email

@cerahmed
Copy link
Author

cerahmed commented May 7, 2022

Enjoy it Terry.

Another bug I found which you can also inspect in the above logs file is that applying "No SuperDisplay" profile also disables BOTH USB monitors (SuperDisplay + Spacedesk) .. that is, even before restarting the PC.

The "No SuperDisplay" profile is a profile that should disable Superdisplay (to make the screen go black for some time when I don't need it) while keeping the smaller Spacedesk monitor active. However, applying it disables both Superdisplay and Spacedesk displays.

Cheers,
Ahmed

@terrymacdonald
Copy link
Owner

terrymacdonald commented May 7, 2022 via email

@terrymacdonald
Copy link
Owner

Apologies for the delay on this. Been working on the DRS Settings functionality first, and will look at this next.

Thanks
Terry

@terrymacdonald terrymacdonald added this to the 2.4.0 milestone May 14, 2022
@terrymacdonald
Copy link
Owner

@cerahmed we need to test the NVIDIALibrary code and only that library code. It's time to break out NVIDIAInfo....

I need you to test NVIDIAInfo, a little app that I wrote specifically to test the NVIDIALibrary that I wrote. Because I want to only test the video manipulation works with multiple video cards, we will only use that for testing this. Once we can confirm that it all works then I'll roll it into DisplayMagician.

Can you please download and extract the latest NVIDIAInfo zip file to a folder on your computer from here:
NVIDIAInfo-v1.7.4.zip

Open a PowerShell window, and change to the same folder that you extracted NVIDIAInfo into.

IMPORTANT - These instructions are likely to fail, so I need you to save/rename the NVIDIAInfo.log file as shown below. Each run of NVIDIAInfo overwrites the previous NVIDIAInfo.log, so I need you to rename it each time so it doesn't get overwritten. I need to see the log file entries to know what is broken.

Please complete the following instructions in this specific order:

Create a Superdisplay layout with some of your screens then:

  • Save the first config as NVIDIAInfo save first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-save.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)

Next, restart you PC. We need to do this so that it cycles the Superdisplay code so we can see what changes.

Next, after the reboot, create a second superdisplay windows display layout:

  • Save the second windows display as NVIDIAInfo save second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-save.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Check if the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we want it to NOT be equal)

Next swap back to the first display layout:

  • Load the first windows display as NVIDIAInfo load first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-reload.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save first-reload.cfg
  • Make sure the second windows display config is NOT equal with NVIDIAInfo equal second.cfg (we DO NOT want it to be equal)

Next swap back to the triple screen display layout again:

  • Load the second windows display as NVIDIAInfo load second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-reload.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save second-reload.cfg
  • Make sure the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we DO NOT want it to be equal)

Once that series of tests are done, please include the following files in a ZIP file, and upload the ZIP to this github issue through your web browser (click and drag the file from your File explorer into Github and it will upload):

  • first.cfg
  • first-reload.cfg
  • NVIDIAInfo-first-save.log
  • NVIDIAInfo-first-reload.log
  • second.cfg
  • second-reload.cfg
  • NVIDIAInfo-second-save.log
  • NVIDIAInfo-second-reload.log

I'm hoping that there will be a slight difference between the CFG files created, as that will then help point me at what is changing between reboots with the Superdisplay driver.

Also - Just to let you know - it may be that I cannot fix this. It may be that Superdisplay changes it's settings after a reboot too much and I cannot find a way to work around that. I'll do my best, but I can't promise anything.

Thanks
Terry

@cerahmed
Copy link
Author

Hey Terry,

Thanks for your time! Below are the results of my testing.

NOTES:

  1. All display profiles are with SuperDisplay in extended mode; no duplicate screens, no Nvidia Surround, etc.
  2. Only change I made between first.cfg and second.cfg is the location of the SuperDisplay monitor to easily identify the changes in monitors identifications after the reboot.
  3. All instructions were strictly followed.

RESULTS:

  1. All the equality checks (7 count) returned NOT equal.
  2. Loading first.cfg fails.
  3. Loading second.cfg succeeded as expected.

Also - Just to let you know - it may be that I cannot fix this.

I'm a hobbyist programmer myself and I totally understand that 💯

Reboot Issue.zip

@terrymacdonald
Copy link
Owner

@cerahmed this is confusing the heck out of me.

2022-05-24 22:23:48.9444|WARN|DisplayMagicianShared.SharedLogger|WinLibrary/SetActiveConfig: The combination of parameters and flags specified is invalid. Display configuration not applied. So trying again without SDC_FORCE_MODE_ENUMERATION as that works on some computers.
2022-05-24 22:23:48.9444|WARN|DisplayMagicianShared.SharedLogger|WinLibrary/SetActiveConfig: Retry. The combination of parameters and flags specified is invalid. Display configuration not applied. So trying again without any specific data other than the topology as that works on some computers.

From the above, I can see that the problem is with the WinLibrary, not the NVIDIALibrary. It is not liking the the SetDisplayConfig command and is returning an ERROR_INVALID_PARAMETER error: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdisplayconfig

From that page we can see that ERROR_INVALID_PARAMETER means "The combination of parameters and flags specified is invalid.".... which doesn't help that much as far as error messages go.

My intuition is telling me that the following happened:

  • You saved the first cfg
  • You then modified the display layout and saved as second cfg
  • You rebooted
  • You then attempted to apply the first cfg (which didnt work thanks to WinLibrary error above)
  • You then attempted to apply the second cfg (which did work as display layout hadn't been changed).

So I think we need to do a slightly different test. I need to try and see what changes between the saved config files for the same display after a reboot.

So please do these steps for me please using NVIDIAInfo.....

Delete the NVIDIAInfo config files and log files you made earlier.

Create a Superdisplay layout with some of your screens then:

  • Save the first config as NVIDIAInfo save original.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-original-save.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal original.cfg (we want it to be equal)

Next, restart your PC. We need to do this so that it cycles the Superdisplay code so we can see what changes.

Next, after the reboot, all your displays should stay in exactly the same display layout. We need to take a snapshot of that config to see what has changed.:

  • Save the post reboot windows display config as NVIDIAInfo save reboot.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-reboot-save.log"
  • Check if the reboot windows display config is equal with NVIDIAInfo equal reboot.cfg (we want it to be equal)
  • Check if the original windows display config is equal with NVIDIAInfo equal original.cfg (we want it to be equal)

Once that series of tests are done, please include the following files in a ZIP file, and upload the ZIP to this github issue through your web browser (click and drag the file from your File explorer into Github and it will upload):

  • original.cfg
  • reboot.cfg
  • NVIDIAInfo-original-save.log
  • NVIDIAInfo-reboot-save.log

Again, I'm hoping that there will be a noticeable difference between the CFG files created so I can see what changes after a reboot. I need it to be a repeatable change in order to code around the problem....

Thanks
Terry

@cerahmed
Copy link
Author

cerahmed commented May 25, 2022

Hey Terry,

That is very weird.

I'm currently at work with my laptop and the same superdisplay tablet connected to it (one laptop monitor + Superdisplay monitor), which experiences the same issue when rebooting. So the following testing is done with my laptop.

Results:

  1. All equality checks returned Not equal.
  2. Display profile original.cfg and reboot.cfg should be identical, I have not changed the position nor any settings for the Superdisplay monitor after rebooting.
  3. Followed your instructions as stated and below are the attached results.
  4. As an additional testing, I tried loading back original.cfg after I saved all the files you required above. Interestingly, although it still fails (just like the desktop setup) with the following code:
Attempting to apply NVIDIA display config from .\original.cfg
ERROR - NVIDIAInfo Windows CCD settings were not applied correctly.

However the Superdisplay is not getting disconnected/go black this time, it just keeps working.

If you remember, trying to load a profile after rebooting on my PC causes USB monitors to get disconnected/go black. This is not happening on my laptop using the same superdisplay version/tablet/settings.

  1. Also tried loading the reboot.cfg .. it works as expected.

Test files.zip

@cerahmed
Copy link
Author

What is confusing me is that none of the equality checks passes. I believe this means that some settings are not captured in the .cfg file that gets saved and we're trying to load. Just a tought.

@terrymacdonald
Copy link
Owner

terrymacdonald commented May 25, 2022 via email

@terrymacdonald
Copy link
Owner

@cerahmed I found some issues with the way equality testing was being performed (some specific issues with Equals on some objects and the way that Windows changes the display name ordering). I've now updated NVIDIAInfo to v1.7.5 and added the NVIDIA 3D Settings tracking and Windows DPI Scaling (per source mode only).

I think that some of the changes I've made may help fix your Superdisplay issue, so I think it's worth testing again.

Can you please download and extract the latest NVIDIAInfo zip file to a folder on your computer from here: https://github.com/terrymacdonald/NVIDIAInfo/releases/tag/v1.7.5

Open a PowerShell window, and change to the same folder that you extracted NVIDIAInfo into.

IMPORTANT - These instructions are likely to fail, so I need you to save/rename the NVIDIAInfo.log file as shown below. Each run of NVIDIAInfo overwrites the previous NVIDIAInfo.log, so I need you to rename it each time so it doesn't get overwritten. I need to see the log file entries to know what is broken.

Please complete the following instructions in this specific order:

Create a Superdisplay layout with some of your screens then:

  • Save the first config as NVIDIAInfo save first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-save.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)

Next, restart you PC. We need to do this so that it cycles the Superdisplay code so we can see what changes.

Next, after the reboot, create a second superdisplay windows display layout:

  • Save the second windows display as NVIDIAInfo save second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-save.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Check if the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we want it to NOT be equal)

Next swap back to the first display layout:

  • Load the first windows display as NVIDIAInfo load first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-reload.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save first-reload.cfg
  • Make sure the second windows display config is NOT equal with NVIDIAInfo equal second.cfg (we DO NOT want it to be equal)

Next swap back to the triple screen display layout again:

  • Load the second windows display as NVIDIAInfo load second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-reload.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save second-reload.cfg
  • Make sure the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we DO NOT want it to be equal)

Once that series of tests are done, please include the following files in a ZIP file, and upload the ZIP to this github issue through your web browser (click and drag the file from your File explorer into Github and it will upload):

  • first.cfg
  • first-reload.cfg
  • NVIDIAInfo-first-save.log
  • NVIDIAInfo-first-reload.log
  • second.cfg
  • second-reload.cfg
  • NVIDIAInfo-second-save.log
  • NVIDIAInfo-second-reload.log

I'm hoping that there will be a slight difference between the CFG files created, as that will then help point me at what is changing between reboots with the Superdisplay driver.

Also - Just to let you know - it may be that I cannot fix this. It may be that Superdisplay changes it's settings after a reboot too much and I cannot find a way to work around that. I'll do my best, but I can't promise anything.

Thanks
Terry

@cerahmed
Copy link
Author

Hey Terry,

The equality seems to work correctly now after running the tests, however loading the profile saved before rebooting still cannot be reloaded.

Below is the response for each instruction:

  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)

Returns equal.

  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)

Returns equal

  • Check if the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we want it to NOT be equal)

Returns NOT equal

  • Load the first windows display as NVIDIAInfo load first.cfg

Failed to load with the following error ERROR - NVIDIAInfo Windows CCD settings were not applied correctly..

  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)

Returns NOT equal.

  • Make sure the second windows display config is NOT equal with NVIDIAInfo equal second.cfg (we DO NOT want it to be equal)

Returns equal.

  • Load the second windows display as NVIDIAInfo load second.cfg

Didn't load because it's the current active profile The display settings in second.cfg are already installed. No need to install them again. Exiting..

  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)

Returns equal.

  • Make sure the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we DO NOT want it to be equal)

Returns NOT equal.

Result.zip

@terrymacdonald
Copy link
Owner

terrymacdonald commented May 31, 2022 via email

@cerahmed
Copy link
Author

cerahmed commented May 31, 2022

Hi Terry,

So I went back home after work, and tried the same on my PC (the files shared above were from my laptop/superdisplay setup).
Although my comments above are valid for the PC, however I wanted to share new files which could help you detect the issue.

I created first.cfg and second.cfg this time without modifying the position of the Superdisplay (the one I shared in my previous comment has different monitor positions between both profiles).

So this time, when checking equality after restarting and creating an identical profile, first.cfg is equal to second.cfg, and loading first.cfg gives back The display settings in .\first.cfg are already installed. No need to install them again. Exiting.. So I wanted to share both profiles for your review as well.

** P.S. Edit - Additional Informaation: So now with both first.cfg and second.cfg equal in NvidiaInfo check, I tried the following:

  1. After rebooting and saving second.cfg, I changed the position of the SuperDisplay, then tried loading second.cfg - it loaded no problem.

  2. I then went ahead and changed the position again, and tried loading first.cfg - and it did not load!

My guess is that there're some settings not captured by NvidiaInfo that's causing the issue.

Identical Profiles Before and After Reboot.zip

@terrymacdonald
Copy link
Owner

@cerahmed Great news. I installed Superdisplay on my PC and found the underlying issue. And it was a fairly major error.

The issue was with the Windows display config patching we have to do after each restart of Windows. Microsoft decided to make it really difficult to use their APIs, and change the Adapter identifiers each time windows restarts. This means each time we load a previously saved display config, we have to 'patch it' with the current adapter identifiers that are valid during this run of Windows.

The problem was that some of the patches were not being properly applied, meaning that the config being handed to Windows was a mix of the new adapter ids and the old adapter ids. This just wouldn't work. Also, it would have affected the display config matching logic, as the two configs being compared wouldn't have matched even if all of the other settings were exactly equal.

So, I have now ensured that the adapter ids are being patched correctly, and I've slightly changed where the patching takes place to remove some of the repeated patching that was being done. The result is a Windows display config that works even after a reboot!

Next steps are to get a new version of CCDInfo built, after which I will get you to test. Once we've confirmed CCDInfo works, I'll then make the same changes to NVIDIAInfo, and once that tests ok, we'll roll the changes into DisplayMagician v2.3.2.

Thanks
Terry

@terrymacdonald
Copy link
Owner

@cerahmed ok - we'll skip straight to testing NVIDIAInfo as I had some time to copy the WinLibrary changes over after work today. So, Can you please do the following tests for me with NVIDIA v1.7.6 as that is the version that contains the fixes you need.

Can you please download and extract the latest NVIDIAInfo zip file to a folder on your computer from here: https://github.com/terrymacdonald/NVIDIAInfo/releases/tag/v1.7.6

Open a PowerShell window, and change to the same folder that you extracted NVIDIAInfo into.

Please complete the following instructions in this specific order:

Delete all previous .CFG and .LOG files as we want to start again.

Create a Superdisplay layout with some of your screens then:

  • Save the first config as NVIDIAInfo save first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-save.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)

Next, create a second windows display layout with a disabled superdisplay screen:

  • Save the second windows display as NVIDIAInfo save second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-save.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Check if the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we want it to NOT be equal)

Next - REBOOT your computer. You need to do this so that we can see if it will work after a reboot now.

Next swap back to the first display layout:

  • Load the first windows display as NVIDIAInfo load first.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-first-reload.log"
  • Check if the first windows display config is equal with NVIDIAInfo equal first.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save first-reload.cfg
  • Make sure the second windows display config is NOT equal with NVIDIAInfo equal second.cfg (we DO NOT want it to be equal)

Next swap back to the disabled super display display layout again:

  • Load the second windows display as NVIDIAInfo load second.cfg
  • Rename the NVIDIAInfo.log file to Rename-Item -Path "NVIDIAInfo.log" -NewName "NVIDIAInfo-second-reload.log"
  • Check if the second windows display config is equal with NVIDIAInfo equal second.cfg (we want it to be equal)
  • Save a copy of the current display config for me to compare: NVIDIAInfo save second-reload.cfg
  • Make sure the first windows display config is NOT equal with NVIDIAInfo equal first.cfg (we DO NOT want it to be equal)

Once that series of tests are done, please include the following files in a ZIP file, and upload the ZIP to this github issue through your web browser (click and drag the file from your File explorer into Github and it will upload):

  • first.cfg
  • first-reload.cfg
  • NVIDIAInfo-first-save.log
  • NVIDIAInfo-first-reload.log
  • second.cfg
  • second-reload.cfg
  • NVIDIAInfo-second-save.log
  • NVIDIAInfo-second-reload.log

I'm REALLY hoping this all works as expected, as I performed the exzct same test on my PC and it worked perfectly. 🤞

Thanks
Terry

@terrymacdonald terrymacdonald modified the milestones: 2.5.0, 2.4.0 Jun 2, 2022
@terrymacdonald
Copy link
Owner

This fix will go out in the next release of DisplayMagician v2.4.0.

@cerahmed
Copy link
Author

cerahmed commented Jun 2, 2022

Hey Terry,

V1.7.6 Tag only has the source code, can you please compile it so I can test it?
Otherwise I can test V1.7.7 which has the executable.

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 2, 2022 via email

@cerahmed
Copy link
Author

cerahmed commented Jun 9, 2022

Glad to hear that you were able to identify some bugs!

I uninstalled the older version of Display Magician and installed V2.4.0.26 as requested.

  1. Created extended and duplicated profiles as before.

  2. Switching back and forth between them works flawlessly! (before restarting)

  3. Restarted my PC then tried loading extended for three times -> unfortunately it failed.
    Right After Applying Extended (for 3 times) - Failed.zip

  4. Tried loading duplicated after extended has failed and the USB screen went black -> it worked!
    Right After Applying Duplicated - Works.zip

  5. Went ahead and closed DisplayMagician and relaunched it, then tried loading extended -> it worked as I expected.
    Closed and Relaunched App - Applied Extended - Works.zip

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 9, 2022 via email

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 9, 2022

@cerahmed So, managed to get Superdisplay and SpaceDesk working together on my system, and have started testing. One thing I found out is that the taskbarlayout recording can have a delay of 15 seconds, so I have added some checks to prevent the display config from saving until Windows updates the registry with the taskbar layout. This means it can take up to 20 seconds to save a config, but at least it ensures that the config is always valid.

I was able to duplicate the Superdisplay screen on the SpaceDesk screen, but I cannot duplicate other screens on either of those two. It appears either they or Windows prevent this from happening.

I then updated CCDInfo with the new logic so that we can concentrate on the WinLibrary code to see where the error may lie.

In my testing, it seems that either Superdisplay or SpaceDesk is stopping the display swap from a duplicated display layout to an extended one. It looks like its something to do with the way that the display drivers themselves work. I can't find any error at the moment that is specifically a DisplayMagician one. I'll keep looking and I'll keep testing, but at this point it looks like I may not be able to fix it in DisplayMagician.

One thought I had was, why do you need to use Superdisplay AND SpaceDesk? It looks like SpaceDesk can run more than one screen with the cool client->server driver model it uses. You might be able to have two SpaceDesk tablets and not use Superdisplay, and it might work ok. In fact, I'm going to test that later on tonight to see if it works.

Thanks
Terry

@cerahmed
Copy link
Author

Hi Terry,

I will try the steps I made in my last comment with my laptop that only has SuperDisplay installed; will share the results later.

The reason why I use both is because my first choice is SuperDisplay, as it can drive an android tablet at its full resolution @ 120Hz! That's crazy good for using it as a pen tablet monitor and other stuff. But SuperDisplay can only work with one device at a time, so I use SpaceDesk to drive my small phone next to my main monitor displaying sensor gauges and volume controls, etc.

Last thought, I've been using NvidiaInfo V1.7.7 to temporarily adjust my monitor settings ever since I tested it, and it worked 99% of the time (sometimes it requires loading the profile twice for it to work) - but as far as my testing goes, it does work!

@terrymacdonald
Copy link
Owner

@cerahmed Did NVIDIAInfo v1.7.9 work ok?

Another thought I had was that it could be that the display layout changes need to fully be changed before being saved. The reason I say this is that I currently monitor the windows taskbar location using some registry keys. These registry keys aren't actually updated until 15-20 seconds after the display layout change has happened. It is possible that the taskbar layout needs to settle down to it's final position before saving the setting.

We can actually try this with CCDInfo v1.7.9b that I've included here:
CCDInfo-v1.7.9b.zip

Please extract CCDInfo v1.7.9b to a new folder.

Can you please create two new display layouts similar to your existing extended and duplicated ones, but can you please wait for 30 seconds after you have made the display layout changes, and then save them with CCDInfo after the 30 seconds has passed? The idea is that we are giving windows time to set all the things it needs to set, and then after its finished making changes we'll save then. I'm hoping this may work...

Then please try swapping between those two new display configs, and see if that works ok.

This version of CCDInfo also has a few bugfixes in it that may have been causing you issues. That, combined with the waiting 30 seconds before saving a new display layout may help things work a bit better.

Please then send me through the log files and cfg files to analyse.

Thanks
Terry

@cerahmed
Copy link
Author

Hey Terry,

NvidiaInfo V1.7.9 works 99% of the time - as I elaborated in this comment. Sometimes I have to apply the extended profile twice for it to load properly.

As for CCDInfo, I've done what you've requested:

  1. Created extended profile in Windows Settings -> waited +30 seconds -> saved extended.cfg.
  2. Created duplicated profile in Windows Settings -> waited +30 seconds -> saved duplicated.cfg.
  3. Tried loading extended.cfg -> terminal gives me that it has been applied correctly, but I can't see any changes!
  4. Tried loading duplicated.cfg -> terminal says profile is already applied and no changes took place.

I haven't restarted the PC during the above testing.

All logs and cfg's are attached.

CCDInfo.zip

@terrymacdonald
Copy link
Owner

ok @cerahmed, I found some possible problems with the config that DisplayMagician generates which may be causing your issue.

1. The extended.cfg lists 3 different adapters in there:

"DisplayAdapters": {
    "75441": "\\\\?\\PCI#VEN_10DE&DEV_2484&SUBSYS_261719DA&REV_A1#4&2de8dd5b&0&0008#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}",
    "7077733": "\\\\?\\SWD#{1BAAD4AC-CD9D-4207-B4FF-C4F160604B13}#0000#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}",
    "118797": "\\\\?\\SuperDisplay#Display#1&3343b12b&6&1234#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}"
  },

This is good.

The duplicated.cfg only has 2 adapters listed (75441 and 7077733). Yet it still has the old adapter ID 118797 still in the duplicated.cfg. That isn't going to work. I think that is the cause of this error in CCDInfo-reload-duplicated.log:

2022-06-11 15:02:51.2562|ERROR|DisplayMagicianShared.SharedLogger|WinLibrary/PatchAdapterIDs: Exception while going through the display config HDR info to update the adapter id

2. I've found the following in the CCDInfo-reload-extended.log:

2022-06-11 15:02:13.6467|ERROR|DisplayMagicianShared.SharedLogger|WinLibrary/PatchAdapterIDs: Saved adapter 118797 (AdapterName is \\?\SuperDisplay#Display#1&3343b12b&6&1234#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}) doesn't have a current match! The adapters have changed since the configuration was last saved.

This is a weird, one, as the GetCurrentAdapterIDs function doesn't see the adapter 118797 at all! And I think I know why. At the moment I only get the list of adapters from the config. The only display connected to adapter 118797 is the cloned display, and that is getting 'patched' as part of the cloned config scanning. This then means that any GetCurrentAdapterIDs scanning that is while your cloned display is active is effectively "missing" the adapter of the cloned display (118797).

This is a REALLY subtle bug. It will only affect users in the following scenario:

  • If the user has an video card (adapter) with only only one display, AND
  • If the display is showing a clone of another display

In that one case, the GetCurrentAdapterIDs will miss the adapter and the config will not work.

Right. Well knowing the problem is only half the battle. I now have to figure out a way to get around those 2 issues I've listed. I'd have a think about it over the next few days and then we'll go from there.

Thanks
Terry

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 13, 2022

Deeper inspection proves that 2. may not be quite the error I thought it was. I actually don't use the previous config as part of GetCurrentAdapterIDs, but instead actually specifically call windows QueryDisplayConfig requesting all adapters that windows has connected, even if they are not currently in use. This would successfully pick up the SuperDisplay adapter if it was connected. I've been through the code in detail and it is working as it should.

My only thought then is that at the time you ran that command that the Superdisplay was possibly in its 'paused' state. I've noticed that Superdisplay automatically unplugs the monitor from Windows when it loses connection, or if the Superdisplay app is switched from the foreground. The monitor disappears from the Windows Display Settings layout at the same time as the displays switch and re-position the other displays that are left.

It could be that the load extended.cfg command happened just as the Superdisplay went to sleep, and that means that the superdisplay adapter 118797 disappeared from windows. DisplayMagician would have queried windows, and would have seen a missing display adapter. This would have been considered an error by WinLibrary, and the load extended.cfg wouldn't work.

If this is the case, then there isn't anything I can do to change DisplayMagician. DisplayMagician needs to work this way to stop people using invalid configurations. I'll try doing a bit more experimentation with Superdisplay to see if I can figure out the reasons that it disconnects. I may need to add a polling command into CCDInfo to see if I can track the moments that Superdisplay disconnects itself from Windows, and see if there is a pattern I can see in when it happens.

Anyway - sorry for the bad news :/

Thanks
Terry

@cerahmed
Copy link
Author

It could be that the load extended.cfg command happened just as the Superdisplay went to sleep, and that means that the superdisplay adapter 118797 disappeared from windows. DisplayMagician would have queried windows, and would have seen a missing display adapter. This would have been considered an error by WinLibrary, and the load extended.cfg wouldn't work.

Hey Terry, I can assure you that this is not the case, as I'm 100% SuperDisplay is indeed active during the loading process. Forgot to mention that I'm using SuperDisplay beta release (which you can enroll in via Google Play Store) - this beta version includes the option to always keep the app running even in background (even though I never dismissed the app during loading the profile).

I don't think the beta version acts differently than the stable version in its core; but this is a point I was supposed to mention at the beginning👌

@cerahmed
Copy link
Author

cerahmed commented Jun 13, 2022

One fact to give us hope is that -as I mentioned earlier- NvidiaInfo V1.7.9 still works ok (despite having to load extended.cfg twice for it to load).

My gut feeling is that the order at which DisplayMagician "patches" the monitors' ID's is supposed to be moved to a more logical place - perhaps right before loading the profile, instead of at the startup of DisplayMagician.

I haven't examined the source code to come up with this conclusion, but I have noticed that closing DisplayMagician and relaunching it fixes the issue as I mentioned in my previous testing .. so I though it might be the reason why.

@cerahmed
Copy link
Author

P.S. as I seem to be one of only a few people (if any) using SuperDisplay together with DisplayMagician, I feel like you've given this issue so much time and effort. Please feel free to set it aside and come back to it whenever you're completely free to work on it. No pressure and I have no expectation to a soon resolution but I'm glad to do any testing whenever you have a new release 👍👌

@terrymacdonald
Copy link
Owner

My gut feeling is that the order at which DisplayMagician "patches" the monitors' ID's is supposed to be moved to a more logical place - perhaps right before loading the profile, instead of at the startup of DisplayMagician.

@cerahmed patching IDs happens when the profiles are loaded from the disk, as they are then theoretically in a 'patched' state in memory, This was deliberately chosen as it is needed for the equality testing to work. Most people don't have a changing set of video adapters :).

That said, it is likely that it will be more common to have software based video adapters, or that there are external adapters that can be plugged in partway through DisplayMagician running. This never used to be a problem because a new DisplayMagician instance would be created each time that a shortcut was run. This would mean that DisplayMagician would generally always have the most current display adapters in it's memory. Now that I have moved to a single instance model to fix other issues and speed up general usage, this appears to be one of the more subtle side effects of that.

One point to note, is that when you click on a profile it use it in DisplayMagician, it currently compares the existing config currently running with the one that has been selected. If they are different, then DisplayMagician attempts to load it. I will have to sit down when I am not so tired and work through the process properly to see whether I could insert an additional check/update process that would reupdate the relevant parts, but I will need to sit down on model out where there could be changes needed.

I really don't want to break what's there though, so we have to be pretty surgical with any changes we make. This is a core part of DisplayMagician and something that has taken over a year to get to a generally working state.

Thanks
Terry

@terrymacdonald
Copy link
Owner

@cerahmed some hopefully good news! I have another CCDINfo to try, and this implements the new adapter logic that will store all adapters in the system along with the profile. This should stop that other error from being the cause of it not working, but it equally may cause another issue :). Let's see.

Can you please download CCDInfo v1.8.1 from here https://github.com/terrymacdonald/CCDInfo/releases/tag/v1.8.1

Then please delete your old duplicated.cfg and extended.cfg

Then please create them again, waiting 30 seconds after making the screen changes before you save the CFG files.

Then please do the same series of CCDInfo tests we have been doing last time again. This may cause some more errors, but it should get us further down the line at least!

If this works, then we'll try again without waiting 30 seconds (to test if that makes a difference).

Thanks
Terry

@cerahmed
Copy link
Author

Hey Terry!

I have downloaded CCDInfo V1.8.1 and did the required testing all without restarting for now.
Still it seems like nothing is changing, but hopefully the logs are richer this time!

  1. I created the extended profile in Windows settings -> waited for 30 seconds -> saved extended.cfg and renamed log to save-extended.

  2. I then created the duplicated profile in Windows -> waited for 30 seconds -> saved duplicated.cfg and renamed log to save-duplicated.

  3. Tried loading extended.cfg -> nothing seem to have changed but terminal returns success -> renamed log to load-extended.

  4. Tried loading duplicated.cfg -> again nothing seem to have changed and the terminal returns it's already installed -> renamed log to load-duplicated.

Attached are the results.

CCDInfo 1.8.1.zip

@terrymacdonald
Copy link
Owner

@cerahmed I think I'll have to park it for a bit. I need to squash some other people's bugs and then get this release out. It's WAY more reliable that 2.3.1.60, so I'd better release it sooner rather than later.

I'll circle back to this when I have some more time avilable.

@terrymacdonald terrymacdonald modified the milestones: 2.4.0, 2.5.0 Jun 21, 2022
@terrymacdonald
Copy link
Owner

@cerahmed I've just confirmed a bug with the Windows DPI scaling that may be the cause of your issue. From my testing it seems some hardware (most likely laptops) return data outside the expected range. I've now made DisplayMagician tell windows what DPI awareness it has, so that we get the guaranteed right DPI settings, and I've made WinLibrary handle expected values (as in my testing these values still result in the correct Windows DPI Scale being applied).

I've also adjusted the process for adding a '.old' to the end of the older json config files so that it does it to all of them reliably. This should help avoid DisplayMagician wanting to patch the wrong things.

I've also added a Windows display path processing improvement that should help on devices with a lot of display paths that have accumulated over time. Display Paths are the bits in windows that link a display source (a particular desktop) with a display target (a particular monitor). Windows keeps track of every monitor it's ever seen, and that eventually leaves a lot of stale entries in the list. We now try to skip over the ones that can't be used.

I've wrapped this all up into a new test version of DisplayMagician v2.4..0.64 that should fix the issue you're experiencing. To test this, please perform the following:

  • Download DisplayMagician-v2.4..0.64.zip from here: DisplayMagicianSetup-v2.4.0.64.zip
  • Unzip the zip file
  • Run the DisplayMagician-v2.4..0.64.msi
  • See if it loads properly!
  • Go to the Display Profiles window
  • Delete any old Display Profiles listed in there
  • Use Windows Setup or NVIDIA Control Panel or AMD Adrenalin to set up a display layout you want
  • Swap back to DisplayMagician and save the display layout as a Display Profile.
  • Swap back to Windows Setup or NVIDIA Control Panel or AMD Adrenalin to set up another display layout you want
  • Swap back to DisplayMagician and save the display layout as a Display Profile.

Once you have finished setting up your Display Profiles, please try to swap between them using the Apply button the Display Profiles window. This is critical as I want to test that everything works using the simplest way to do so.

Please then create a Support ZIP File by going click the Settings button on the Main page, and then clicking on the Create Support ZIP File button. Please upload the ZIP file using you make to this issue using your Web Browser, so that I can see if this fixed the problem for you.

Hope it works!

Thanks
Terry

@cerahmed
Copy link
Author

Hey Terry,

Thanks for the update!

I went ahead and removed the old version, restarted my laptop (I'm on laptop now, I'll try with my PC when I'm home), installed the test version, restarted the pc again and did the following tests:

  1. DisplayMagician shows the warning message on the first launch.
  2. It loads the app correctly the first time.
  3. Created the extended profile in Windows Settings -> saved Extended profile.
  4. Created the duplicated profile in Windows Settings -> saved Duplicated profile.
  5. Switched to the Extended using the apply button in DisplayMagician -> it worked!
  6. Switched back to the Duplicated profile using the apply button -> it failed.
  7. Saved a support log.

First Trial - Duplicated Fails.zip

  1. Now that Duplicate has failed and SuperDisplay is in disabled state by DisplayMagician, and while Display Magician is open, I went to Windows Display Settings and tried to enable the SuperDisplay monitor in duplicate mode -> DisplayMagician crashed with the following error:

image

  1. Now that DisplayMagician has crashed and closed, and the SuperDisplay is in duplicate mode, tried launching DisplayMagician -> it crashes immediatly.

  2. Went to Windows Display Settings and put SuperDisplay in extended mode -> launched DisplayMagician -> it launches normally.

  3. Saved a second support log right after I launched DisplayMagician in hope that it shows why it crashed.

Reopened DisplayMagician after changing windows monitors to extended.zip

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jun 29, 2022 via email

@terrymacdonald
Copy link
Owner

@cerahmed I've just released DisplayMagician v2.4.1.4 out, and it may help with your Superdisplay issue (it also may not). GIve it a go and tell me how it goes. 🤞

@cerahmed
Copy link
Author

cerahmed commented Aug 4, 2022

Hey Terry,

Thanks for the update and apologies for the late response, got busy for a while.
I couldn't locate v2.4.1.4 in the releases page, could you please share a link?

@terrymacdonald
Copy link
Owner

terrymacdonald commented Aug 4, 2022 via email

@terrymacdonald
Copy link
Owner

@cerahmed I released a new version of DisplayMagician (v2.5.0) that may fix your SuperDisplay issue. Can you please check to see if it does?

Thanks
Terry

@cerahmed
Copy link
Author

cerahmed commented Jan 5, 2023

Hi Terry,

Thanks so much for the update! I'll check it out tonight (local time) when I get back home.
I'll keep you posted!

@cerahmed
Copy link
Author

cerahmed commented Jan 6, 2023

Hey Terry,

I had some time to play around with the newer version, got to say that it seems to work much better than the previous ones! Kudos to you.

The Duplicated profile (Superdisplay tablet mirrors the main 27" display) seems to work fine across restarts.
However, Extended profile (Superdisplay as extended monitor) only work before rebooting the PC.

That's a little weird. However I saved a log .zip for each step before and after restarting, hoping it'll lead you to figure out what's going on. I'll continue to experiment with various scenarios (perhaps keeping only one USB monitor connected at a time, currently I have two - Superdisplay (android tablet) and Spacedesk display (android phone).

One thing also to note which is not a big deal: The viewport of Display Magician (the section that shows the visual configuration of the monitors) does not show the USB monitors. It's only a visual thing but just wanted to bring it up to your attention.

Attached is the log numbered by order of actions and the file names are self explanatory.

Troubleshooting Files.zip

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jan 6, 2023 via email

@cerahmed
Copy link
Author

cerahmed commented Jan 7, 2023

Hi Terry,

You brought up a good point that might be a core to the problem! Let me explain my experience with Superdisplay without Display Magician:

  1. Everytime I want to connect my android tablet to my PC using Superdisplay (be it after manually disconnecting, restarting the PC, etc.), I have to launch the Android App then select my PC from the list.

  2. When Superdisplay is connected to my PC, it always connects as an Extended Display, and its position is reset! For example, if before disconnecting Superdisplay I set it to be BELOW my main monitor, connecting next time will reset its location to be on the RIGHT of my main monitor! It does not remember the last position I have set it prior to disconnecting.

I have emailed Superdisplay support several times regarding this issue, and now that you brought it up I believe it has something to do with Display Magician not working properly with it.

Superdisplay might be assigning a new monitor ID for every session after connecting, losing whatever settings were set before reconnecting.

However what made me doubt this speculation is the fact that the Duplicated profile works just fine, which -I believe- also relies on Superdisplay ID to apply the profile correctly.

@terrymacdonald
Copy link
Owner

terrymacdonald commented Jan 7, 2023 via email

@terrymacdonald
Copy link
Owner

@cerahmed, I've been working with others on a new version of DisplayMagician which may be able to help you with the issue you're experiencing. Could you please try this latest version?
DisplayMagicianSetup-v2.6.0.508.zip

This version uses all the Video Libraries at once now (NVIDIA, AMD and Windows), and that means that it is able to correctly pick up and configure all the displays at once. It should be more reliable than earlier versions, and it may do things like set the correct primary display more reliably. I'm not really sure how this will impact software based screens like Superdisplay, but with testing we should be able to find out.

I'm hoping this will work, but at the very least it should allow DisplayMagician to boot up enough for you to create a Support ZIP File. Let's see whether I've fixed it 🤞.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants