multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

MTA won't open after alt-tabbing #1103

Open ekvatorx33 opened 4 years ago

ekvatorx33 commented 4 years ago

Describe the bug
the title says it all, after alt-tabbing from desktop to mta a few times, MTA simply won't open anymore and I'm forced to close it with the task manager.

I've tried reinstalling MTA, move it to a different direction, changed the resolution from fullscreen to windowed (which made it flicker and lag really hard), nothing would work.

I can't find any reason for this to happen, as no updates on both my windows and MTA were made the day this problem appeared. windows 10 1903 version

Video
https://www.youtube.com/watch?v=GFDSh7Fq2cs

Version
1.5.7

botder commented 3 years ago

I can test it out, but I don't think patching a frequently updating driver is a good idea.

T-MaxWiese-T commented 3 years ago

I have now installed the Windows 10 21H1 and the latest NVIDIA driver. I noticed that the latest NVIDIA driver also installs a Control Panel Windows 10 app. It needs to be investigated further. The problem still exists. Nvidia control panel screenshot

botder commented 3 years ago

My system is running NVIDIA Game Ready Driver 466.11 and Windows 10 Pro 20H2 (19042.985)

ds1-e commented 3 years ago

I have updated Windows 10 Pro to version 20H2 (19042.985), and NVIDIA drivers to 466.27. Switched back from borderless to full screen mode, and i can confirm that issue is gone for me, can freely use alt-tab 😁

I've discovered that after around 10-20~ alt-tabs MTA still can hang. So it fixes issue a bit, but doesn't resolve it :(

Dutchman101 commented 3 years ago

I can test it out, but I don't think patching a frequently updating driver is a good idea.

I doubt there are other options, Nvidia is too big to still listen to individuals making bug reports. Like most big tech companies these days. Also, even if it somehow manages to pass Tier-1 support and reach actual Nvidia developers, who knows if enough DX9 games are affected for them to care enough. So the chance this gets fixed is minimal.

We can do it, and see the result across driver versions and later updates. If it causes problems, we can use a signature scanner to see if that function (the loop it hangs on) is still unchanged and therefore safe to patch.

Alternatively, use a survey for driver versions in use by MTA players, and see if for the most common versions it would all be the same (including the required patch). Then make it automatically abort if a signature check fails, and the end result will be that we will have the majority of affected MTA users covered against the hangs. At least, for a while, until it needs a revision due to newer driver versions. Then if there's no manpower for revision, we can just support affected users by instructing them to rollback their driver to a version that is confirmed to work (to which we know MTA patching is successfully applied), then everyone has the chance to play MTA without issues. Bottom line, if we can minimalize the impact for a significant group of users, then maybe we should.

MTA has a file somewhere that contains "NVHACKS" which would probably be suitable for this patching, ccw did a bunch of stuff in the past to work around Nvidia driver issues in MTA. Or who knows that stuff is even responsible for this issue in some way..

Dutchman101 commented 3 years ago

Also @botder could you post a screenshot of the entire block of pseudocode in that location (while (1) loop it hangs on) for future reference and potentially for others that want to assist in bringing this driver bug to Nvidia's attention? As more reports could mean better chances they will pick it up.

botder commented 3 years ago

Top-level function, which executes a function for a linked list of objects

NOTE: This for-loop had between 5-15 iterations, when I tested it. When the bug happens, each iteration takes around 20 seconds.

image

Second-level function

NOTE: Nothing exciting happens here

image

Third-level function

NOTE: Nothing exciting happens here

image

Bottom-level function

NOTE: Here lies the devil

image

NOTE: I thought that the WaitForSingleObject is the culprit, because it almost always appears in the call stack whenever I paused execution, but after hooking it, I could verify that it works properly and returns almost immediately (also confirmed by logging the calls). image

14:52:41.413 - WaitForSingleObject(00000E90, 1)
14:52:41.429 - WaitForSingleObject(00000E90, 1)
14:52:41.445 - WaitForSingleObject(00000E90, 1)
14:52:41.461 - WaitForSingleObject(00000E90, 1)
14:52:41.477 - WaitForSingleObject(00000E90, 1)
14:52:41.493 - WaitForSingleObject(00000E90, 1)
14:52:41.509 - WaitForSingleObject(00000E90, 1)
14:52:41.525 - WaitForSingleObject(00000E90, 1)
14:52:41.541 - WaitForSingleObject(00000E90, 1)
14:52:41.557 - WaitForSingleObject(00000E90, 1)
14:52:41.573 - WaitForSingleObject(00000E90, 1)
14:52:41.589 - WaitForSingleObject(00000E90, 1)

NOTE: I don't know why, but this function returns 0x8876021C {HRESULT, DDERR_WASSTILLDRAWING} whenever it exits from the long running loop. image

NOTE: Any for anyone looking for the bottom-level function, it uses this particular string image

botder commented 3 years ago

The entire function: https://pastebin.com/Awznyf3a

T-MaxWiese-T commented 3 years ago

I can now report that the latest NVIDIA driver does not solve the problem and neither does Windows 10 21H1. Therefore, it makes no real sense to hope for updates but should fix or work around it code-wise.

Dutchman101 commented 3 years ago

Nice details @botder, but just to guarantee future reportability (to Nvidia) can you at last include your graphics driver version, MD5 of your nvd3dum.dll and the exact offset of the instruction where that function (while (1) loop) is located at in your IDA view?

They might ask for things that would be a bunch of work to dig up again.

botder commented 3 years ago

nvd3dum.dll

MD5: ff42f4956bbbdd4872d7be9d52788719 SHA1: e9224d881f3b65e251ad2c4a052436dba7a2da15 File description: NVIDIA WDDM D3D Driver, Version 466.11 File version: 27.21.14.6611 Product name: NVIDIA Windows WDDM D3D driver Product version: 27.21.14.6611 Size: 20,4 MB (21.483.520 bytes)

while (1) { } is located at nvd3dum.dll+0x74F2D0 in function nvd3dum.dll+0x74F0D0 (bottom-level), which is called from nvd3dum.dll+0x74EFF2 (third-level). The callee is called from nvd3dum.dll+0x75F48A in function nvd3dum.dll+0x75F3D0 (second-level). In the top-level function nvd3dum.dll+0x75F860 is the second-level function call at nvd3dum.dll+0x75F9EE.

Dutchman101 commented 3 years ago

I received this message:

fix

So possibly, disablefso.reg

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\System\GameConfigStore]

"GameDVR_FSEBehaviorMode"=dword:00000002

"GameDVR_HonorUserFSEBehaviorMode"=dword:00000001

"GameDVR_FSEBehavior"=dword:00000002

"GameDVR_DXGIHonorFSEWindowsCompatible"=dword:00000001

also attached as file to this comment: disablefso.reg.zip

.. resolves the problem. It would be nice to have some affected Nvidia users test this method.

If true, then it would make sense as a problem between Nvidia drivers and Xbox GameDVR (included in Windows 10 and often called "faulty" on the internet, due to the amount of bugs that include stutter, lag and not being able to alt-tab) due to "Fullscreen optimization" feature, and confirming this can help us to write a workaround to ship with MTA

Due to the amount of issues with GameDVR in general, i would advise to go beyond that .reg file and also disable DVR entirely by:

.. and that would be another thing to try if anyone affected that's testing can't immediately resolve the alt-tab problem using that .reg file

ds1-e commented 3 years ago

@Dutchman101 I've used registry file, and it seems to fix it. However game still becomes dark after alt-tabbing once.

Lpsd commented 3 years ago

@Dutchman101 I've used registry file, and it seems to fix it. However game still becomes dark after alt-tabbing once.

I believe the screen becoming dark is a completely separate issue which there are already solutions for by using the NVidia control panel / profiles.

ds1-e commented 3 years ago

I believe the screen becoming dark is a completely separate issue which there are already solutions for by using the NVidia control panel / profiles.

Yeah thanks. I've used NVIDIA filters to increase brightness :)

Xenius97 commented 3 years ago

I can't reproduce with AMD. This bug is only with nvidia cards.

image

Einheit-101 commented 2 years ago

Now if i am running MTA in full screen i get a nvd3dum.dll crash: Module = C:\WINDOWS\System32\DriverStore\FileRepository\nvmii.inf_amd64_b2c4a831580adff2\nvd3dum.dll Code = 0xC0000005 Offset = 0x008D124C

I am now installing that .reg file and try again... What a pathetic BS

Proxy-99 commented 2 years ago

I have used that registry file the issue gone really thanks this issue really annoying me for so many years xd

Dutchman101 commented 2 years ago

Considering positive feedback on that workaround (that it solves the problem), maybe approach it by forcing Fullscreen Optimizations to disabled as long MTA is running.. instead of patching Nvidia driver bugs, which is dirtier

Actually, FSO (a Windows 10 & 11 feature) is OS bloat that reduces gaming performance and causes a range of stability issues. It wouldn't even be such a bad idea to help users by disabling it in a dialog, like one we use to fix permissions.. "Compatibility: disable FSO. Proceed?"

It's for good reasons that so many users on the internet are seeking to disable it and keep it that way

lodsdev commented 1 year ago

I have AMD graphics card and this also happens, it's not just with NIVIDIA graphics.

Dutchman101 commented 1 year ago

I have AMD graphics card and this also happens, it's not just with NIVIDIA graphics.

@lodsdev

Last week i started to experience black screen when tabbing out of the game on fullscreen on AMD (RX 6600) as well, it never happened to this PC before and im thinking it might be related to AMD GPU driver update (currently using Adrenalin 22.10.1) but im not available to test with rolling back anytime soon.. maybe someone else that starts to experience it, like you, can check about driver versions. I'm also not ruling out a Windows OS update until further testing.

In which case it may be unrelated to this issue, but a new bug in AMD/ATI drivers. Note that this particular case is recoverable with CTRL + DEL and task manager, you find a way to tab out from there and then back into the game

lodsdev commented 1 year ago

When active this options, for one moment work correctly, but don't fix the bug. I am currently using drive version Adrenalin 21.3.1 (previous driver) with Windows OS 10 build 21H2. I not believe it be compatibility of drivers. image

ekvatorx33 commented 1 year ago

you still think the problem is with the video card :D

Mav3rick-5708 commented 1 year ago

And there I was, thinking I was the only one with such a problem. For those who are still struggling with it -

I just stumbled across this topic and it's been 2 years since I've had that annoying "MTA alt tab" issue. I'm not exactly sure what the cause of the problem is but I'm guessing it had / has something to do with NVIDIA's GPU's and or, it's win10 drivers, seeing that it mainly happens to Nvidia users (Nvidia myself), and there is an inability of AMD users reproducing the issue.

The problem was fixed for me, after tweaking CSGO's performance actually, back in 2021. There are 4 main registry files that I suggest you download and merge to your registry to fix this, which are: Disable DVR 1, Disable DVR 2, fullscreenfix, Game Optimizations.reg - I noticed that whenever I do not have these 4 REG tweaks installed, especially after new windows 10 installs, that MTA alt-tab issue would be there. I personally install these after every windows install, because it also helps in overall system tweak for my other games.

The link can be found in the description: Watch: 14:50 / 18:43 • ADVANCED Tweaks

https://www.youtube.com/watch?v=YmgosEdKFaA&ab_channel=Panjno

Download: CS2022 FPS Pack.zip and only install the 4 registry files, since those are the only fixes you need.

ScreenShot_20230412002712

Insigne commented 3 months ago

This problem is still present after all these years. (Version 1.6 r22388) If you're still experiencing this, take a look at these comments, they've helped. Dutchman's comment | Mav3rick's comment

TechSneeker commented 2 months ago

helppls