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
456 stars 19 forks source link

Unhandled exception when opening Game Shortcut Library after creating a shortcut #154

Closed bertro514 closed 1 year ago

bertro514 commented 2 years ago

Unable to access the Game Shortcut Library anymore. Getting "Unhandled exception: Object reference not set to an instance of an object" every time. This started happening after I created a new shortcut to start MSFS (non-steam). as well as two other apps (SPAD.Next and LittleNavMap) before MSFS.

Repro of the current situation:

  1. Open DisplayMagician
  2. Click Game Shortcuts
  3. The Library's main area is crossed out with a red X and the "Unhandled Exception" error pops up: 2022-10-30 13_17_54-NVIDIA GeForce Overlay

Repro of the original trigger:

  1. Open DisplayMagician
  2. Click "Game Shortcuts"
  3. Click New
  4. Select your display profile (in my case, I left it to my current setup)
  5. Select your audio preference (in my case, I left it as it was)
  6. Select apps to run before the game. (in my case, I browsed to the LittleNavMap and to the SPAD.Next executables)
  7. Select the game to start. In my case, it was MSFS non-Steam Edition (from the Microsoft Xbox store). No extra arguments. Note that the game did not have an icon.
  8. I left the post-game options as they were,
  9. Click Save. The library view crashes with the above message, but the shortcut is created and you can place it on your desktop.
  10. Every time you open the Game Shortcut Library after that, you get the error and are unable to see your shortcuts.

Logs: DisplayMagician-Support-20221030-1317.zip

Enviroment (please complete the following information):

Additional context I had created other shortcuts (to Steam games) before and they all worked fine. I suspect this error might be due to the icon being blank.

terrymacdonald commented 2 years ago

@bertro514 Sorry for the delay in responding.

It looks as though the Microsoft Flight Sim shortcut is invalid. You can see here that there are 'null' entries for the images in the shortcut entry here:

{
    "UUID": "a4f9bd13-067a-444d-bddf-fae12bb7d467",
    "Name": "MSFS",
    "AutoName": false,
    "ProfileUUID": "8452baed-84d6-4000-995f-e6c41f4bbd20",
    "DisplayPermanence": 1,
    "AudioPermanence": 1,
    "CapturePermanence": 1,
    "Category": 0,
    "ProcessPriority": 0,
    "DifferentExecutableToMonitor": null,
    "ExecutableNameAndPath": "F:\\MSFS\\Microsoft Flight Simulator\\Content\\gamelaunchhelper.exe",
    "ExecutableArguments": "",
    "ExecutableArgumentsRequired": false,
    "RunExeAsAdministrator": false,
    "ProcessNameToMonitorUsesExecutable": true,
    "GameAppId": "",
    "GameName": "",
    "GameLibrary": 0,
    "Hotkey": 0,
    "StartTimeout": 20,
    "GameArguments": "",
    "GameArgumentsRequired": false,
    "DifferentGameExeToMonitor": "",
    "MonitorDifferentGameExe": false,
    "AudioDevice": "",
    "ChangeAudioDevice": false,
    "AudioVolume": -1.0,
    "SetAudioVolume": false,
    "CaptureDevice": "",
    "ChangeCaptureDevice": false,
    "CaptureVolume": -1.0,
    "SetCaptureVolume": false,
    "StartPrograms": [
      {
        "Priority": 1,
        "Disabled": false,
        "ProcessPriority": 0,
        "Executable": "C:\\Program Files (x86)\\Little Navmap\\littlenavmap.exe",
        "Arguments": "",
        "ExecutableArgumentsRequired": false,
        "CloseOnFinish": true,
        "DontStartIfAlreadyRunning": false,
        "RunAsAdministrator": false
      },
      {
        "Priority": 2,
        "Disabled": false,
        "ProcessPriority": 0,
        "Executable": "C:\\Program Files\\SPAD.neXt\\SPAD.neXt.exe",
        "Arguments": "",
        "ExecutableArgumentsRequired": false,
        "CloseOnFinish": true,
        "DontStartIfAlreadyRunning": false,
        "RunAsAdministrator": false
      }
    ],
    "StopPrograms": [],
    "OriginalIconPath": "F:\\MSFS\\Microsoft Flight Simulator\\Content\\gamelaunchhelper.exe",
    "OriginalLargeBitmap": null,
    "ShortcutBitmap": null,
    "SavedShortcutIconCacheFilename": "C:\\Users\\bertr\\AppData\\Local\\DisplayMagician\\Shortcuts\\a4f9bd13-067a-444d-bddf-fae12bb7d467.ico",
    "SelectedImage": {
      "UUID": null,
      "Name": null,
      "Order": 0,
      "Source": null,
      "Image": null,
      "Size": "0, 0"
    },
    "AvailableImages": []
  }

Those shouldn't be null. I'm not sure why they are null to be honest! It looks like there must have been an error that occurred while creating the MSFS shortcut.

I've checked the logs you sent, and there isn't any logs showing the creation of the MSFS shortcut itself. I'd need those logs to be able to see the error and fix it.

So, can you please do the following two things:

Once you've created the MSFS game shortcut, please try and run it and see if it works. Please then create a Support ZIP File and upload it here using your web browser. It will hopefully give me some nice log entries and I'll be able to fix the bug 🤞 .

Thanks Terry

bertro514 commented 2 years ago

Hi Terry. Thank you so much for looking into this. Is there a way to delete just that shortcut and try to re-create it? Since the library is broken, I can't delete it from the UI, and I wasn't able to find any config files where I could remove it from. Is the only way to completely remove the app and reinstall it? (Ideally I'd like to avoid that because I have another shortcut that works just fine).

BTW, huge thanks for making this app in the first place. It's a life saver for us simmers with multiple monitors!! Robert.

bertro514 commented 2 years ago

Hi again. I was actually able to "blindly" delete the MSFS shortcut. It looks like this error only prevents the display of the library, but the icons are actually there "under the hood", so by moving the mouse around, I got the MSFS icon tooltip and was able to delete it. 2022-11-05 11_09_01-DisplayMagician - Game Shortcuts

I've attempted to re-create the shortcut. Attaching the log bundle. DisplayMagician-Support-20221105-1114.zip

I've tried creating the shortcut without any pre-launch items, just in case one of those was the culprit. But no, it seems the MSFS executable is the issue. I also tried creating a shortcut to just any random local executable that doesn't have an icon and got the crash, so that seems to be the trigger indeed.

Thanks, Robert.

terrymacdonald commented 1 year ago

@bertro514

Sorry or the delay in getting back. I ended up having to take some time away from DisplayMagican development as life just got too busy. Things have gotten more manageable now, so I'm catching up on previously logged issues to see where I got up to.

I've looked at your latest log files, and I cannot see where the issue is! I think I must not be logging the right part of the application, so I'm missing some sort of vital log entry that will help me see where the problem is. Luckily, I have MSFS myself (installed through Steam though), so I'll do some testing with it myself to see if I can replicate the error.

I was contemplating adding Xbox Library support to DisplayMagician, so if my testing doesn't fix the issue, then hopefully if I do decide to add the Xbox Library support it might make things work properly for you.

Thanks Terry

terrymacdonald commented 1 year ago

@bertro514 ,

I just had a thought! I wonder if the gamelauncher.exe doesn't have an icon file in it! Could you please have a look at the "F:\MSFS\Microsoft Flight Simulator\Content\gamelaunchhelper.exe" file and check if it has an icon in it? The easiest way to do that is to download IcoFx from https://icofx.ro/ (click the green download now) and install it. Then run IcoFx and click on the 'Extract Icon from Files' menu item and choose your gamelaunchhelper.exe:

image

After you click Extract, you should see something like this:

image

Hopefully there are one or more groups of icon files in the file. In this example there is a single group of icons, with 5 different icons in it. Can you please take a screenshot of this window and paste it into this issue so that I can see it?

That should hopefully give me more information about why that file isn't getting an icon.

Thanks! Terry

bertro514 commented 1 year ago

Hi @terrymacdonald ,

First of all, no need to apologize for the delay. We all have busy lives and I definitely don't expect instant responses. It's free software, I'm just grateful for the work you've already put into it!!

Secondly, your thought is exactly what I had discovered too: the library crash is due to the fact that my MSFS executable does not have any embedded icon file. I've also been able to reproduce the crash with other executables that don't have icons (e.g. random .exe files from the Windows folder). A couple weeks ago I used a program called ResourceHacker to inject an icon into the gamelaunchhelper.exe file, and after I did that, DisplayManager was able to perfectly create the MSFS shortcut without any problem. So the lack of an icon is definitely the culprit. I'd recommend having a default image that DisplayManager can use when the selected game executable doesn't have an embedded icon. That could prevent such crashes, not only for me, but also for other folks who might want to run old games or other executable programs that don't have an embedded icon.

Cheers, Robert.

terrymacdonald commented 1 year ago

Hi @bertro514,

That's awesome news! I know the exact area where the bug lies now thanks to that description. Well done.

Weirdly, the code already should default to a default image. It should use the DisplayMagician icon for executables, and it uses the icon from the game library if it is a library game e.g. Steam icon. There must be a bug somewhere in there that I need to find. But at least it's something I know I can squash!

I'll add it to my list, and get on to in within the next few weeks. I'd quite like to get out a new build shortly, as I recently found out that the next version of Steam has changed the file format slightly, and so I need to get the new code out to my users before Steam Beta changes to Steam mainline.

Anyway - I might ask you to do some testing when I get a version ready to drop. I'd love to confirm with you that the issue is fixed before I release a new DM version to the public.

Thanks for the kind words too!

Terry

bertro514 commented 1 year ago

Hi @terrymacdonald,

Amazing to hear that! I hope you manage to find the bug. I would be very happy to test not only this bug, but anything else you might need help testing. I have a 4-monitor config, and I have Steam, the Xbox app, the EA app and a bunch of old-school standalone games that I can test with on my PC.

Looking forward to hearing from you. Happy holidays! Robert.

terrymacdonald commented 1 year ago

@bertro514 I have been doing some testing with executables without any icons in them, and DisplayMagician is working fine for me using the latest test version. Can you please test creating some game shortcuts for executables with no icons in them, and see if it works better?

The new test version of DisplayMagician adds 'applications' in addition to executables, and it tries to look through the install applications and find the best way to run those applications automatically. It also allows you to choose specific executables the old way as well ' That's the 'Choose Exe from your computer' button. Can you please try the new 'Choose Exe from your computer' button on your exe's that don't have an icon and see if now works?

image

If you have any errors please ensure that your DM logging level is set to 'TRACE' from within the Settings page, and then see if you can cause the issue, then send me another Support ZIP File.

DisplayMagicianSetup-v2.5.0.331.zip

This version of DisplayMagician adds quite a few new features (e.g. a built in FOV calculator for if you are a simracer) and hopefully works fine. If you could install and give it a test I'd really appreciate it!

bertro514 commented 1 year ago

@terrymacdonald, this is amazing! I love the new "applications" feature, and it does work perfectly and solves the icon issue. I tried the MSFS executable as well as a random .exe file, and it worked in both cases: it provided a placeholder icon with the ability to change that to a custom icon. No crashes, no fuss. It just works! I also really love the feature of uploading any image file to be the icon! I've actually used it to replace the (ugly to me) X-Plane icon with a nice custom pic of the Boeing737 I like to "fly" in the game. I'm going to do that for MSFS too, as I really don't like their text-heavy icon :) The FOV feature is really awesome too. I don't do much car simming (hard to steer a Ferrari with my Boeing yoke, haha), and my displays are not the same size (22" + 34" + 22"), so I can't use this feature, but it does seem like a very useful feature that takes the guesswork out of setting up your sim. I remember all the trial & error to get my X-Plane and MSFS fow in a good place.

Kudos and thank you for the great updates, and please count on my for testing any features or bugs in the future.

Happy New Year! Robert.

terrymacdonald commented 1 year ago

Excellent news! I'll consider this issue closed then for now. I hope to finally get some free time to finish up the last few outstanding issues and then put out a new release.

Thanks Terry

On Wed, 28 Dec 2022, 04:05 bertro514, @.***> wrote:

@terrymacdonald https://github.com/terrymacdonald, this is amazing! I love the new "applications" feature, and it does work perfectly and solves the icon issue. I tried the MSFS executable as well as a random .exe file, and it worked in both cases: it provided a placeholder icon with the ability to change that to a custom icon. No crashes, no fuss. It just works! I also really love the feature of uploading any image file to be the icon! I've actually used it to replace the (ugly to me) X-Plane icon with a nice custom pic of the Boeing737 I like to "fly" in the game. I'm going to do that for MSFS too, as I really don't like their text-heavy icon :) The FOV feature is really awesome too. I don't do much car simming (hard to steer a Ferrari with my Boeing yoke, haha), and my displays are not the same size (22" + 34" + 22"), so I can't use this feature, but it does seem like a very useful feature that takes the guesswork out of setting up your sim. I remember all the trial & error to get my X-Plane and MSFS fow in a good place.

Kudos and thank you for the great updates, and please count on my for testing any features or bugs in the future.

Happy New Year! Robert.

— Reply to this email directly, view it on GitHub https://github.com/terrymacdonald/DisplayMagician/issues/154#issuecomment-1365967923, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLU5LGV3YFUP36VGZRNP5TWPMATXANCNFSM6AAAAAARSMMBBE . You are receiving this because you were mentioned.Message ID: @.***>