psiberx/cp2077-cet-kit

Game Crash when opening game menu using 'P' key or 'M' key

KitKatMeowski opened this issue · 22 comments

Narrowed this down to mods using GameUI, including the Demo mod 'whereami'.
Tested this by disabling (completely removing all mods from "\bin\x64\plugins\cyber_engine_tweaks"), confirmed the game was no longer crashing.

Added my own WIP mod first, confirmed the crash occurs with my mod enabled.
Confirmed further that the issue is caused when using GameUI, by testing with just the Demo mod enabled and no other mods.

Steps to reproduce:
install just the whereami mod from the README and press M to view the map or J for journal, or P for the in-game menu.
Issue doesn't occur if i press i to bring up the menu, or escape.

Stack Trace from the CP77 Crash Reporter:
Error reason: Unhandled exception

Expression: EXCEPTION_ACCESS_VIOLATION (0xC0000005)
Message: The thread attempted to read inaccessible data at 0x10000002F.
File: <Unknown>(0)

I know of the crash when opening the Map using the controller (holding start button). I tried to reproduce it on keyboard and no crash for me. Did you have a controller connected while testing this?

Yes I did have an XBox controller connected. I have removed the controller and tried restarting my PC, still getting the crash.

By the way, until I found the workaround let me know how you planning to use GameUI. I can help you to integrate the lib and probably avoid the crash with current version.

Making a mod that is only relevant in the New Game > Character Creation / Appearance editor Menu and should not be displayed or running in any other context. At the moment I use GameUI to check when the player is in this menu, and when they leave the menu.

Really all I need is to know when they are in the Character Creation screen and when they leave.

registerForEvent('onInit', function()

    GameUI.Observe(function(state)
        -- Is Player in the Character Appearance screen?
        if state.menu == 'NewGame' and state.submenu == 'Customization' then
            -- Show Window

        elseif state.lastSubmenu == 'Customization' then
            -- Hide Window
        end
    end)
end)

You can use this snippet instead of GameUI:

registerForEvent('onInit', function()
    Observe('MenuScenario_CharacterCustomization', 'OnEnterScenario', function()
        -- Show Window
    end)
    Observe('MenuScenario_CharacterCustomization', 'OnLeaveScenario', function()
        -- Hide Window
    end)
end)

I committed potential fix. Can you try it?

Will do! Currently at work, but I will test this as soon as I get home.

Sadly this is still occurring for me with the new GameUI version 0.9.7.
Not that it will help, but can I possibly provide you with anything from the crash report, or the whole thing sav included?

I doesn't seem to be related to the save (game state), I checked this with another modder.

But it would be very helpful if you can try something else. Since I can't reproduce the crash it's hard to find the exact place where the crash is happening. I have three main suspicions.

  1. Observer for SwitchToScenario on lines 466-472
  2. Observer for OnOpenMenuRequest on lines 482-488
  3. Observer for OnCloseHubMenu on lines 490-495

If you can try commenting them out one by one to find which one is failing this would be a major help.

The issue doesn't occur when the block below is commented out

  1. Observer for SwitchToScenario on lines 466-472

Thank You! And it's a good news because I know at least one alternative for this code. I'll prepare it soon.

Awesome! thank you for looking into it

Pushed an update.

No go still the same issue with SwitchToScenario. Wonder why my environment is so different.

So now OnEnterScenario causes the crash? If you comment this new part 466-476 then no crash?

upd: btw I only updated the main file and not the ones on the examples.

Actually no, I am wrong this is not happening now. I was using the GameUI with the whereamI mod to test not the version you just updated sorry.

Let me test it also with the code I had one second

Looks like its fixed to me! Cant get it to happen again. Sorry for the confusion there for a second

Ok so the game no longer crashes when opening the menu from within an active game, however I now get a crash in my code just after selecting Game difficulty in the New Game menu. Commenting out lines 466-476 stops the crash from occurring.

Trying something new, will update soon.

Pushed new version.

Got the new version and tested in game and in the new player menu.
No more crash! xD I think we have it!
Sorry I had to disappear for a short while.

Oh man, it's so good to hear .)