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
183 stars 51 forks source link

Overlay Error in Old Source Games (early api shutdown + reinitialize again) #207

Closed ghost closed 3 weeks ago

ghost commented 3 weeks ago

When I try to play games that use Half-Life 2 (Portal, Half-Life 2 Episode 1, etc.) I get the errors shown in the attachment. If you don't use the Overlay, there is no problem. You can access STEAM_LOG.txt here.

Source Game Error 1

Source Game Error 2

Source Game Error 3

otavepto commented 3 weeks ago

why the hell is the game calling shutdown early

[83 ms, 83540 us] [tid 11420] SteamAPI_Shutdown() 

only to re-initialize again. the solution (at least for the overlay) is to make it object based, but then not every part of the emu is expecting that.

otavepto commented 3 weeks ago

test the cold client loader and post its debug log

ghost commented 3 weeks ago

It works fine with Cold Client Loader. I wonder why it doesn't work with the normal version? Anyway, you can access STEAM_LOG.txt and COLD_LDR_LOG.txt files here.

otavepto commented 3 weeks ago

with the cold client loader, the original api (steam_api.dll) does it's job properly, with dll replacement the emu has to do the same, but currently that's not the case. thanks for the logs by the way.

I can see that the original api is refusing or ignoring that first shutdown request (not present in the log), in your second log (with cold client) you'll find only one entry at the very end as expected

[26160 ms, 26160184 us] [tid 1244] SteamAPI_Shutdown() 
[26160 ms, 26160393 us] [tid 1244] Steam_Client::BReleaseSteamPipe() 1
[26160 ms, 26160566 us] [tid 1244] Steam_Client::BShutdownIfAllPipesClosed() 
[26160 ms, 26160736 us] [tid 1244] Steam_Controller::Shutdown() 
[26160 ms, 26160743 us] [tid 1276] background_thread() exit
[26160 ms, 26160951 us] [tid 1244] Steam_Overlay::UnSetupOverlay() 
[26161 ms, 26161147 us] [tid 1244] Steam_Overlay::allow_renderer_frame_processing() disabled frame processing (count=29, force=1)
[26291 ms, 26291296 us] [tid 1244] Steam_Overlay::UnSetupOverlay() free-ing any images resources
[26292 ms, 26292305 us] [tid 1244] Steam_Client::BShutdownIfAllPipesClosed() all pipes closed
[26308 ms, 26308267 us] [tid 1244] SteamAPI_UnregisterCallback() 6D390A70

this is actually a legitimate problem like the one in issue #192 will look into it.

otavepto commented 3 weeks ago

by the way something wrong with your .ini

[5 ms, 5583 us] [tid 1244] load_all_config_settings() final ini start ---------
[5 ms, 5749 us] [tid 1244] load_all_config_settings() []
[5 ms, 5890 us] [tid 1244] load_all_config_settings() ip_country=US

empty section name [], recheck all ini files again, no need to specify everything, only what you need

ghost commented 3 weeks ago

Actually, instead of deleting the settings I don't use from the .ini file, I put # at the beginning. I just realized that I forgot to put it for ip_country=US! My mistake. It should be correct now.

ghost commented 3 weeks ago

with the cold client loader, the original api (steam_api.dll) does it's job properly, with dll replacement the emu has to do the same, but currently that's not the case. thanks for the logs by the way.

I can see that the original api is refusing or ignoring that first shutdown request (not present in the log), in your second log (with cold client) you'll find only one entry at the very end as expected

[26160 ms, 26160184 us] [tid 1244] SteamAPI_Shutdown() 
[26160 ms, 26160393 us] [tid 1244] Steam_Client::BReleaseSteamPipe() 1
[26160 ms, 26160566 us] [tid 1244] Steam_Client::BShutdownIfAllPipesClosed() 
[26160 ms, 26160736 us] [tid 1244] Steam_Controller::Shutdown() 
[26160 ms, 26160743 us] [tid 1276] background_thread() exit
[26160 ms, 26160951 us] [tid 1244] Steam_Overlay::UnSetupOverlay() 
[26161 ms, 26161147 us] [tid 1244] Steam_Overlay::allow_renderer_frame_processing() disabled frame processing (count=29, force=1)
[26291 ms, 26291296 us] [tid 1244] Steam_Overlay::UnSetupOverlay() free-ing any images resources
[26292 ms, 26292305 us] [tid 1244] Steam_Client::BShutdownIfAllPipesClosed() all pipes closed
[26308 ms, 26308267 us] [tid 1244] SteamAPI_UnregisterCallback() 6D390A70

this is actually a legitimate problem like the one in issue #192 will look into it.

By the way, I forgot to tell you. I use Cold Client Loader with the original emu for achievements.

otavepto commented 3 weeks ago

It works fine with Cold Client Loader. I wonder why it doesn't work with the normal version? Anyway, you can access STEAM_LOG.txt and COLD_LDR_LOG.txt files here.

hmmm are you sure these are debug logs from cold client loader ? you're supposed to use the original steam_api.dll

HuggedJacker commented 3 weeks ago

https://github.com/otavepto/gbe_fork/issues/206#issuecomment-2143966228

ghost commented 3 weeks ago

Now things are going to get a bit complicated. For simplicity I did the tests with Portal (yes, it also gives errors with emu). I did 3 tests in total: 1) Only with emu. It gives an error.

Portal Error 1

Portal Error 2

Portal Error 3

2) Only with Cold Client Loader. The game opens but there are no achievements etc. because there is no emu. 3) Both emu and Cold Client Loader. The game opens and achievements etc. work.

You can access the logs for all of them here.

P.S. Oh, my God, so many logs!

otavepto commented 3 weeks ago

Alright some clarification:

Cold Client Loader (point 2.) didn't work because you didn't even copy the steam_settings folder beside the loader!

What's needed is only 1 scenario:

  1. Restore all game files, everything must be original
  2. Copy Cold Client Loader files/folders and copy your steam_settings folder beside the loader .exe
  3. Edit ColdClientLoader.ini and set the appid and game exe
  4. Launch the loader, but if you got an error with something along the line "arch difference", use the other .exe (steamclient_loader_32.exe vs steamclient_loader_64.exe)
  5. In the debug log make sure you don't see an empty entry for the final ini
    [3 ms, 3159 us] [tid 14780] load_all_config_settings() final ini start ---------
    [3 ms, 3314 us] [tid 14780] load_all_config_settings() final ini end *********
ghost commented 3 weeks ago

I apologize for the confusion. I didn't know that Cold Client Loader has Overlay support! Good to know that. I restored the original steam_api.dll and moved the steam_settings folder next to steamclient_loader_32.exe. All logs should be normal now. Here is the log file.

otavepto commented 3 weeks ago

this required inspection with x64dbg, there are no sneaky integrity checks or any invalid behavior, the game simply calls Steam_InitSafe() in case the user launched it from the .exe not from steam followed by shutdown, this is legitimate use case and a valid function usage.

the code for overlay init/deinit sequence cannot handle this, hence the crash. with cold client loader the conditions are already satisfied so the game doesn't attempt to init/shutdown.

ghost commented 3 weeks ago

It works perfectly. Thank you very much :)