Fexty12573 / SharpPluginLoader

A C# plugin loader for Monster Hunter World
MIT License
29 stars 2 forks source link

[Undesired Behavior] ImGui Doesn't Work Because Of Other Overlays #34

Open GreenComfyTea opened 4 months ago

GreenComfyTea commented 4 months ago

Me on my way to create 10 more issues: 3x

Describe The Problem

The default ImGui key is F9. It was not registering by SPL at all because of GeForce Experience (and Nvidia App) overlay. They have a Alt+F9 hotkey. ImGui wasn't showing and doing if(Input.IsPressed(Key.F9)) Log.Info("F9 is pressed"); printed nothing.

image

Removing the hotkey didn't help, but closing GeForce Experience completely solved the issue.

Personally, I have Nvidia overlay on, and I didn't encounter this issue. But with the other person that did have it we went thru a full troubleshooting process and I can confidently say it was because of Nvidia overlay.

PS. As a side note, it seems that there are ImGuiRenderingEnabled and PrimitiveRenderingEnabled entries that go into loader-config.json. On the first SPL install, if there is loader-config.json file already then ImGui will work by default, but these entries wont be added to the file. But if there is no loader-config.json file then it will be generated with these entries set to false, and ImGui won't work. This is confusing for end users. At least the default value should be true.

PPS. I am not sure \Monster Hunter World\nativePC\plugins\CSharp\Loader\SharpPluginLoader.log is a good place for a log file. Too hidden from end users. I would be prefer if it was in the root folder, alongside regular stracker's log file. That's my personal opinion thou.

PPPS. Another thing, I have several reports claiming that BetterMatchmaking doesn't work with AMD GPUs, it crashes. One of the errors that I got a report of was AccessViolationException that happened in startRequest hook when actually trying to search for sessions. I assume netRequest address was incorrect. I don't know how GPU can affect the functionality of hooks, I checked Reloaded.Hooks issues and didn't see anything related, and I don't have enough information to create a proper issue. So I am just mentioning it here.

To Reproduce

I don't have a reliable way of reproducing the issue.

Expected Behavior

Ideally, all key inputs should work regardless of other overlays. But I don't know if its even doable. As a workaround I can suggest making a entry for changing the ImGui key in a config file.

Priority

Suggested P2 Priority. Inaccessible ImGui makes people think the mods are not working at all. And if not, no menu means no easy customization.

PC Specs

Show/Hide - `GPU`**: Nvidia**

Environment

Show/Hide - `Nvidia Drivers`**: v551.76**
Fexty12573 commented 4 months ago
  1. Adding a Hotkey configuration has been on my Todo list for a while so that's coming for sure.
  2. The default being false is because back when I added those config options, the D3D hooks were still causing quite a few crashes so I set it to false by default as to not inconvenience people that didn't explicitly need it.
  3. I'm not a huge fan of moving it to the root directory, personally I think the root dir is already way too cluttered with various stuff. I'll think about a potentially better place to put it. I might make it configurable as well.
  4. No clue. I might add a crash handler to the loader so people can send actual crash reports.
GreenComfyTea commented 4 months ago

Understandable 👍

GreenComfyTea commented 3 months ago

Disregard my wrong conclusion about keyboard input. It's still related to nvidia overlay, but not to input.

I implemented the Quest End Timer Example example, put log prints for OnUpdate and OnImGuiRender events.

OnImGuiRender is only being called once.

Screenshot when not working ![image](https://github.com/Fexty12573/SharpPluginLoader/assets/30152047/9209c8a3-06e9-4b66-a3b9-be76a291cd15)
Screenshot when working ![image](https://github.com/Fexty12573/SharpPluginLoader/assets/30152047/eebdf86d-ba4d-4102-a8fe-0d1e9313573a)

Not working SharpPluginLoader.log (log from other person) Working SharpPluginLoader.log (my log)

public void OnLoad()
{
    // ...
    KeyBindings.AddKeybind("SkipQuestEnd", new Keybind<Key>(Key.S, [Key.LeftControl, Key.LeftAlt]));
}
public void OnUpdate(float dt)
{
    Log.Info("OnUpdate");

    if(KeyBindings.IsPressed("SkipQuestEnd"))
    {
        Log.Info("OnUpdate: Keybind pressed");
    }

    // Each frame, check if the quest end timer is running and the `Ctrl+Alt+S` keybind is pressed
    if(Quest.QuestEndTimer.Time > 0f && KeyBindings.IsPressed("SkipQuestEnd"))
    {
        // If so, set the quest end timer to be over instantly
        Quest.QuestEndTimer.SetToEnd();
    }
}
public void OnImGuiRender()
{
    // ...
}
public void OnImGuiFreeRender()
{
    Log.Info("OnImGuiFreeRender");
    // ...
}
Fexty12573 commented 3 months ago

Oh great. Just what I needed, hooking conflicts 😆 I will probably change it so it hooks the game's own present function instead of the one on the swapchain itself. That should avoid any sort of conflict with other overlays.

GreenComfyTea commented 3 months ago

I think there is something wrong with the menu key. default F9 value prints a warning. Changing to P key = same.

{
    "logfile": true,
    "logcmd": true,
    "logLevel": "INFO",
    "outputEveryPath": false,
    "enablePluginLoader": true,
    "SPL": {
        "ImGuiRenderingEnabled": true,
        "PrimitiveRenderingEnabled": true,
        "MenuKey": "F9"
    }
}

image

Fexty12573 commented 3 months ago

Interesting, changing it to F7 seems to work for me, could you test that?

GreenComfyTea commented 3 months ago

Nvm, changed it to F7 and it worked, then changed it back to F9 and it worked too. Can't replicate it anymore. No idea what it was.

CodingSheep commented 3 months ago

Adding a comment as well noting that this issue also extends to the menu key straight up not working even with Nvidia's overlay explicitly turned off and after force quitting GeForce Experience (at least on my end. This issue is consistent despite reinstallations). The loader appears to run but the last 2 lines I see in the log are:

[ 07:34:11.6171658 | SPL ] Initializing D3D module for D3D12 [ 07:34:11.9003834 | SPL ] Found D3D12 command queue

No further inputs or changes to the menu key appear to work. I am running on v0.0.6. Same PC GPU specs as Green. Nvidia drivers are on v552.12.

Fexty12573 commented 3 months ago

@CodingSheep Does the game continue running like normal? Have you tried leaving it running for a couple minutes?

It also sounds like another overlay might be conflicting with it, as the renderer never gets initialized according to your log.

CodingSheep commented 3 months ago

@Fexty12573 1) The game ran without any issues for the half hour I just ran it. 2) Let me test running the game with the Steam Overlay disabled and then with ReShade disabled. I do not expect either of these to be the cause of the issue on my end, but it'd be a very funny surprise if either was.

Update: Disabling the Steam Overlay fixed this issue. ReShade's overlay does not appear to conflict.

Fexty12573 commented 3 months ago

I figured. Well as I mentioned in my reply above, I do plan to modify the overlay hooking approach with the release of 0.0.7, so that shouldn't be an issue anymore in the future.

Fexty12573 commented 1 month ago

@GreenComfyTea @CodingSheep It has been a while, I haven't had much motivation recently but I finally got around to making those changes I mentioned to the DirectX hooking. If you don't mind could you check out ed0ed8f84debd84f37612667f1177902d042cedc, and try running the game with it to see if it still conflicts with other overlays? Would be very much appreciated.

GreenComfyTea commented 1 month ago

I didn't had any issues with the previous version, and the new version also works well for me. I've put up a post asking people with the issue to try the new version out. But I think in the past 3 months I only got 1 report that could have been related, but it fixed itself. image

Fexty12573 commented 1 month ago

Alright, thank you. I will switch to this then for 0.0.7. Now I just need to fix a bunch of shit that's not working 😭