otavepto / gbe_fork

Fork of https://gitlab.com/Mr_Goldberg/goldberg_emulator
https://gitlab.com/Mr_Goldberg/goldberg_emulator
GNU Lesser General Public License v3.0
191 stars 55 forks source link

Balatro crashes after changing video settings #89

Closed EsacrihT closed 2 months ago

EsacrihT commented 3 months ago

With the new build "2024_3_8-update_overlay_project" finally the overlay works with this game, but various errors occur.

  1. Show Achievements button do nothing.
  2. Settings are not saved.
  3. Changing the video settings will make the game crash.

Balatro 2024-03-09 04-01-14.webm

Log: STEAM_LOG.txt

otavepto commented 3 months ago

From the logs, it puts the overlay hook into state 2 InGameOverlay::OverlayHookState::Removing then back to 0 InGameOverlay::OverlayHookState::Ready. Every game I tested will always put the hook into state InGameOverlay::OverlayHookState::Reset once the window is resized or the resolution is changed then back to InGameOverlay::OverlayHookState::Ready.

Here the entire context of the hook will be destroyed https://github.com/Nemirtingas/ingame_overlay/blob/50953c380fb877da783414397a64241dd9a76c45/src/Windows/DX11Hook.cpp#L165-L172

I doubt we can do anything about it , but I have a question, did this happen with the older releases too or even the original emu ?

Regarding the Show Achievements button and Save Settings button, this is very similar to the behavior of the game Have a Nice Death, both games never call RunCallbacks API https://github.com/otavepto/gbe_fork/blob/c96b8f9935021042f8549e9ae31431f7e2c174fe/dll/dll.cpp#L442-L447

Which will in turn run the overlay callback https://github.com/otavepto/gbe_fork/blob/c96b8f9935021042f8549e9ae31431f7e2c174fe/overlay_experimental/steam_overlay.cpp#L1524-L1525

The overlay callback takes care of showing the achievements list, saving new settings etc...

I'm not sure why honestly, this is the most important API which every game has to call, this is also why the log file is only a few kilobytes. But it seems a bug somehow in the emu, I'm not convinced both games are just broken.

otavepto commented 2 months ago

Alright, after the new update these are the changes:

  1. Achievements are now shown and unlocked properly
  2. Settings still won't be saved since the game isn't calling RunCallbacks()
  3. Video settings will still crash in nvoglv64.dll (or the similar lib for AMD) because of the hooks of the overlay project, nothing could be done in the emu code, but you can disable the overlay, change resolution, then restore it back

When the resolution is changed, the overlay state will change momentarily to Removing (value 2), but it doesn't recover again properly. It is set back to ready but something is wrong with it caused null pointer access.

Closing this one now since the 2 remaining problems are outside the scope of the emu.

otavepto commented 2 months ago

For the settings problem, I've made a workaround. You can download this build artifact once Github finishes: https://github.com/otavepto/gbe_fork/actions/runs/8579408637