narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
880 stars 67 forks source link

Non functional menus with Tiberian Sun after a period of play #282

Closed tore29 closed 2 months ago

tore29 commented 5 months ago

I have been experimenting with DDrawCompat and Tiberian Sun. I got an issue with the menus in the game.

This bug is a bit annoying as I don't quite know the steps to reproduce it accurately yet. The best way I have done it so far is:

  1. Start a skirmish game
  2. Play the game while opening the pause menu fairly often (space is the hotkey for it)
  3. The pause menu will stretch horizontally. 4a. If you alt-tab then your cursor will vanish 4b. If you attempt to exit to main menu it only shows the main menu background image and nothing else.

I'm on Windows 10 and these are my settings.

AltTabFix = keepvidmemp
ColorKeyMethod = auto
CpuAffinity = 1
CrashDump = mini
DesktopColorDepth = 16
DisplayFilter = point
DpiAwareness = permonitor
FpsLimiter = msgloop(120)
RenderColorDepth = app
SupportedDepthFormats = 16
SupportedResolutions = 640x400, 640x480, 800x600
VSync = off
WinVersionLie = 98

Screenshots of the issue image image2

These are in windowed mode, but it does happen in "fullscreen" too, but I'm unable to take a screenshot when the game ends up in this state.

Logfile DDrawCompat-Game.log

Debug logfile DDrawCompat-Game.zip

tore29 commented 5 months ago

The broken menus are preceded by some minor stuttering

The shift+11 menu freezes the game when it enters this weird state.

tore29 commented 5 months ago

I think I might have found the setting causing this issue

DesktopColorDepth = 16

Played a few missions with this commented out, seemed to work fine.

narzoul commented 3 months ago

I think it's related to the GDI object leak caused by the NVIDIA overlay. If you turn off the "in-game overlay" in Geforce Experience settings, it should fix it. Note that you don't need to actually open the overlay for the leak to happen, it's enough to have it enabled.

You can track the leak by adding "gdiobjects" to the StatsRows setting in DDrawCompat.ini. GDI handles are limited to 10k, so once they're exhausted, all sorts of issues can happen.

The NVIDIA overlay seems to have some problem with the GDI hooks of DDrawCompat, which forces creating 16-bit "device-dependent" bitmaps when the (emulated) display mode has 16-bit color. I assume the overlay runs into some error with 16-bit bitmaps and forgets to delete the bitmap afterwards.

There is a "fix" for it in this other issue: https://github.com/narzoul/DDrawCompat/issues/288#issuecomment-1999487600 With that, you shouldn't have to disable the NVIDIA overlay.

tore29 commented 3 months ago

I think it's related to the GDI object leak caused by the NVIDIA overlay. If you turn off the "in-game overlay" in Geforce Experience settings, it should fix it. Note that you don't need to actually open the overlay for the leak to happen, it's enough to have it enabled.

You can track the leak by adding "gdiobjects" to the StatsRows setting in DDrawCompat.ini. GDI handles are limited to 10k, so once they're exhausted, all sorts of issues can happen.

The NVIDIA overlay seems to have some problem with the GDI hooks of DDrawCompat, which forces creating 16-bit "device-dependent" bitmaps when the (emulated) display mode has 16-bit color. I assume the overlay runs into some error with 16-bit bitmaps and forgets to delete the bitmap afterwards.

There is a "fix" for it in this other issue: #288 (comment) With that, you shouldn't have to disable the NVIDIA overlay.

This fixes the issue. Thanks. :)

narzoul commented 2 months ago

Fixed in v0.5.2.