PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.81k stars 1.62k forks source link

[BUG]: Random Emulator Freeze When Out of Focus #11731

Open AnthonyACS opened 2 months ago

AnthonyACS commented 2 months ago

Describe the Bug

For weeks now I've had the emulator freeze on me seemingly randomly. The only thing that seems consistent is the fact that it can only happen while the emulator window is out of focus. Sometimes as soon as I click off, sometimes a few seconds later while I'm typing a message, others I can leave the emulator in the background and I will randomly hear the game audio cut out several seconds/minutes after clicking off.

When this happens, I can still click on "File", "System" and whatnot, but none of the options like reset or shut down without saving work (even though the latter does gray out some settings), after that all I can do is kill the process via task manager. I've tried different things such as software renderer, disabling the virtual HDD, using version 2.0.2, disabling MTVU and so far none of those have fixed it. I also recall the same thing happening on my other laptop, which barely has anything installed in it at all (Windows 11 though, unlike this one).

Even though I've found no consistent way of triggering it, it's really not all that rare for me. It must have happened to me at the very least 20 times now since the first time and the oldest message I could find where I mention a freeze to my friends is from August 1st

Reproduction Steps

Click off the emulator (say discord, web browser) and wait an indefinite amount of time.

Expected Behavior

No response

PCSX2 Revision

2.1.100

Operating System

Windows 10 (64bit)

If Linux - Specify Distro

No response

CPU

i5-7200U

GPU

Intel HD Graphics 620

GS Settings

gsSettings1 gsSettings2

Emulation Settings

emuSettings

GS Window Screenshots

No response

Logs & Dumps

emulog.txt It's also happened while using the original iso

JordanTheToaster commented 2 months ago

Please update your GPUs drivers. https://www.intel.com/content/www/us/en/download/776137/intel-7th-10th-gen-processor-graphics-windows.html

AnthonyACS commented 2 months ago

Installer_lVIBWllOz4 I already tried this when I got this laptop and this is what I get, I also tried looking for updates from HP and found nothing myself, despite the "Installing this Intel generic graphics driver will overwrite your computer manufacturer (OEM) customized driver." warning that suggests I should be able to install it at my own risk anyway. I'm gonna try following this guide: https://www.intel.com/content/www/us/en/support/articles/000056629/graphics.html and report back if the emulator freezes afterwards, although it did also happen with my other laptop I got like a month ago (not from HP either). Is there anything else I should also try/check in the meantime?

Edit: Finally, I had to first manually uninstall the GPU drivers and then use that other installer while offline. It has definitely helped with OpenGL and Vulkan rendering, however I've had the emulator freeze while using software rendering so I don't know if this is gonna help with that. Either way, assuming it isn't fixed it will probably still take a while for me to trigger it, and if it's fixed it'll take even longer for me to realize and consider the issue has stopped. Should the report remain open for a few days before considering it solved?

terremoth commented 2 months ago

I will test here this night, I have a similar computer config, so I will let the computer with my pcsx2 open and my web browser open but focused, and see if this happens too. But I don't think it will happen to me. Let's see. Tomorrow I came here to say.

terremoth commented 2 months ago

Ok, tested here. I waited for +-8 hours. No problem, no freezing. Couldn't reproduce.

Should the report remain open for a few days before considering it solved?

I think this issue can be marked as solved. If happens again someone will eventually report. It was probably a GPU drivers problem + the Vulkan + OpenGL rendering like you said.

AnthonyACS commented 2 months ago

I wasn't completely sure this would fix it since it also happened with software rendering and I otherwise was using DX11, but at least so far it hasn't happened and last night I did play online for a few hours (usually the only time where I have to click off the emulator to send messages), so that was probably it. Thanks for the help

AnthonyACS commented 2 months ago

Nevermind, it just happened again today, I was watching Youtube for a good while with the emulator running and when I went back to it, same issue as before. Gotta say it's the first time it's happened since I updated the drivers, not sure if it's a coincidence or it actually helped out, but I wouldn't be surprised if it's an issue with Intel iGPU's specifically.

By the way, I can also bring up the Graphics menu (and probably others) while frozen, unlike reset and shut down for instance. Changing the settings doesn't do anything though, it doesn't even bring up warning messages. I also tried disabling achievements but Open debugger was still greyed out, loading save states doesn't work, can still check for updates, clicking on the X icon to close it doesn't do anything either (no idea whether any of this helps or not)

F0bes commented 2 months ago

Can you reproduce the issue, and while the emulator is frozen go to task manager -> details -> pcsx2.exe -> right click -> create dump file and upload it here? (pcsx2.exe might be something else)

Also, let me know the exact version of PCSX2 you are using. Please don't use a self-compiled one, but one you downloaded from our site. Thanks.

AnthonyACS commented 2 months ago

I've only seen the latest reply just now, it has happened a few more times since so I'll make sure to do that next time it happens. My version was downloaded from pcsx2.net (nightly, windows) and I always update it when I get the prompt. At some point I tried the latest stable version instead (2.0.2?) and it happened there too, so I went back to nightly. Either way, I'll also include the emu version when I upload the dump

AnthonyACS commented 2 months ago

The file is about 1.75GB in size, I can't upload it here directly so I'll upload it to google drive and link it for now. If there's a better/correct way of uploading it please let me know and I'll reupload it. It took a while because I haven't played much lately and it's pretty random as it is, but so far it seems consistent in that it can only happen while out of focus. v2.1.137 https://drive.google.com/file/d/1qBu_Pg4FZJomV9l5gYBWEB7eHJyk7dy6/view?usp=drive_link

F0bes commented 2 months ago

Thank you, I'll look into it soon.

F0bes commented 1 month ago

The file is about 1.75GB in size, I can't upload it here directly so I'll upload it to google drive and link it for now. If there's a better/correct way of uploading it please let me know and I'll reupload it. It took a while because I haven't played much lately and it's pretty random as it is, but so far it seems consistent in that it can only happen while out of focus. v2.1.137 drive.google.com/file/d/1qBu_Pg4FZJomV9l5gYBWEB7eHJyk7dy6/view?usp=drive_link

Would you be able to provide me access to the file? I have sent you a request for access. It should apparently be located in your email.

F0bes commented 1 month ago

Unfortunately the dump doesn't give me a clear explanation as to what has happened. I suspect this is some rare race condition. The main (EE) thread is posting a vsync event to MTGS but it's waiting for some atomic. MTGS is waiting for work, so there shouldn't be any atomic held there to cause a deadlock.

There could be the case that something completely different is going on and the state of the threads is just a red herring 😕

AnthonyACS commented 1 month ago

Given the seemingly random nature of the bug I can't 100% confirm this is the case, but a few weeks ago (I'd say at least two) I checked the "Render to separate window" box just to try it and I'm pretty certain it hasn't frozen since, in case that helps. If it does actually freeze at some point I'll come back to correct myself