keeperfx icon indicating copy to clipboard operation
keeperfx copied to clipboard

Intermittent hangs under Wine

Open phoe opened this issue 1 year ago • 49 comments

Debian sid, wine-8.19, KeeperFX 1.0 release.

The game is hanging and starts consuming 200% CPU at seemingly random moments, be it three minutes or an hour into the game. How should I debug this? Is there a binary built with debug symbols so I can produce some sort of stacktrace?

phoe avatar Nov 11 '23 17:11 phoe

There isn't one, but I could make you one. Would you join the discord and ask in #techsupport?

EDIT: Yes, yes there is, the included heavylog version has debug symbols.

Loobinex avatar Nov 11 '23 18:11 Loobinex

I've disabled ambience sounds and I'm trying to check if that fixes anything; if I can still reproduce this, I'll join and ask. Is the heavylog version suitable for running for long games?

phoe avatar Nov 11 '23 21:11 phoe

I've disabled ambience sounds and I'm trying to check if that fixes anything; if I can still reproduce this, I'll join and ask. Is the heavylog version suitable for running for long games?

Not really, it writes a lot of stuff to the log file, making huge log files to the extend that it might slow down everything.

Loobinex avatar Nov 11 '23 21:11 Loobinex

Other users have also reported freezes when using Wine.

yani avatar Nov 12 '23 23:11 yani

Been playing it extensively today, no hangs so far with atmospheric sounds disabled.

phoe avatar Nov 12 '23 23:11 phoe

Been playing it extensively today, no hangs so far with atmospheric sounds disabled.

Why do you figure this is related?

yani avatar Nov 12 '23 23:11 yani

No idea, just my gut feeling. Hangs at random moments during game that seem unrelated to other parts of the game kind of sounds like atmospheric events that are played at random moments during game that are unrelated to other parts of the game.

phoe avatar Nov 12 '23 23:11 phoe

Just got a hang with atmospheric sounds disabled, so that's not the culprit.

phoe avatar Nov 13 '23 22:11 phoe

A shame, but that does not surprise me at all.

Loobinex avatar Nov 14 '23 00:11 Loobinex

Looked a little deeper into that issue, as I am having it too (Arch Linux, Wine 8.20, KeeperFX 1.0, DK Gold from GOG). Symptoms are the same: random hang, 200% CPU. It's worth mentioning though it started happening on "Tickle" level, haven't been experiencing it earlier. From the technical point of view:

  1. strace reported that KeeperFX is waiting on some specific pipe (read(6,)
  2. lsof +c 0 | grep <pipe_id> produces the following:
keeperfx.exe           8569                            przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569                            przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8628 wine_mmdevapi_n      przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8628 wine_mmdevapi_n      przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8629 audio_client_ma      przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8629 audio_client_ma      przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8630 audio_client_ti      przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8630 audio_client_ti      przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8631 wine_dsound_mix      przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8631 wine_dsound_mix      przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8632 keeperfx.exe         przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8632 keeperfx.exe         przem    9w     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8633 SDLAudioP2           przem    8r     FIFO               0,14       0t0     32375 pipe
keeperfx.exe           8569  8633 SDLAudioP2           przem    9w     FIFO               0,14       0t0     32375 pipe
wineserver             8571                            przem   23w     FIFO               0,14       0t0     32375 pipe

Not sure how or why, but it looks sound-related. I would however point to OGG CD-audio (-nocd), because I didn't use this feature when playing previous levels.

madmanxxx avatar Nov 18 '23 20:11 madmanxxx

Not sure how or why, but it looks sound-related. I would however point to OGG CD-audio (-nocd), because I didn't use this feature when playing previous levels.

@madmanxxx: a bit more info, when I was getting my own crashes, I was running wine keeperfx.exe without any switches, so without -nocd.

phoe avatar Nov 18 '23 20:11 phoe

tioning though it started happening on "Tickle" level, haven't been experiencing it earlier. From the technical point of view:

this would be an easy test, run the game with a '-cd' command line option and see if the hangs disappear again.

Loobinex avatar Nov 19 '23 01:11 Loobinex

I got a heavylog logfile where it froze: https://keeperfx.net/uploads/keeperfx-heavylog-wine-freeze.log

yani avatar Nov 20 '23 14:11 yani

@Loobinex said on Discord regarding the heavylog logfile:

it does this bit in loop, in wine:

Sync: update_light_render_area: Starting
Sync: keeper_screen_redraw: Starting
Sync: setup_engine_window: Starting for size (1544,1080) at (376,0)
Sync: redraw_display: Starting
Sync: process_pointer_graphic: Starting for view 1, player state PLAYER_STATE_CTRLDUNGEON, instance 0
Sync: set_pointer_graphic: Setting to 2
Sync: redraw_isometric_view: Starting
Sync: update_explored_flags_for_power_sight: Starting
Sync: engine: Starting
Sync: draw_view: Starting
Sync: display_drawlist: Starting
Sync: draw_view: Finished
Sync: remove_explored_flags_for_power_sight: Starting
Sync: pannel_map_draw_overlay_things: Starting
Sync: draw_gui: Starting
Sync: update_fade_active_menus: Starting
Sync: draw_active_menus_buttons: Starting with 2 active menus
Sync: draw_active_menus_buttons: Finished
Sync: draw_gui: Finished
Sync: message_draw: Starting
Sync: gui_draw_all_boxes: Starting
Sync: draw_tooltip: Starting
Sync: redraw_isometric_view: Finished
Sync: draw_eastegg: Starting
Sync: redraw_display: Finished
Sync: draw_onscreen_direct_messages: Starting

my guess is this fails sometimes on Wine:

TbResult LbScreenUnlock(void)
{
    SYNCDBG(12,"Starting");
    if (!lbScreenInitialised)
        return Lb_FAIL;
    lbDisplay.WScreen = NULL;
    lbDisplay.GraphicsWindowPtr = NULL;
    SDL_UnlockSurface(lbDrawSurface);
    return Lb_SUCCESS;
}

It's just a guess, but this might be a an SDL2 issue.

The SDL2 DLL's were updated in #2557

I suggest testing the the included SDL2 DLL's that were used before: https://github.com/dkfans/keeperfx/releases/tag/v3081

The older SDL2 DLL's can give issues in other parts of the codebase, and were updated with a reason, so we'll most likely not revert the DLL's if using older DLL's fixes it.

I will test too.

yani avatar Nov 20 '23 20:11 yani

FWIW, after updating Wine to 8.21-2 (Arch Linux) the crashes are gone... I've been playing 5+ hours and everything works.

madmanxxx avatar Dec 06 '23 00:12 madmanxxx

FWIW, after updating Wine to 8.21-2 (Arch Linux) the crashes are gone... I've been playing 5+ hours and everything works.

Thanks for the report, please keep us updated! @yani this might interest you?

walt253 avatar Dec 06 '23 02:12 walt253

@phoe does that fix from madmanxxx work for you too?

Loobinex avatar Dec 07 '23 01:12 Loobinex

I've updated wine to 9.0-rc1 and I see no crash after several hours of playing. I'll reopen in the worst case, but let's close it for now. Thanks.

phoe avatar Dec 15 '23 10:12 phoe

Nope, it just hung again.

phoe avatar Dec 16 '23 20:12 phoe

I'm able to reproduce this, where do I obtain the debug version of keeperfx? I don't use Discord.

zaggynl avatar Dec 23 '23 11:12 zaggynl

@zaggynl I would have to make you one, or you can build one yourself. What is it you want to do exactly?

Here is build instructions: https://github.com/dkfans/keeperfx/wiki/Building-KeeperFX

Or would you want me to make you a debug version? For the latest alpha?

Loobinex avatar Dec 23 '23 13:12 Loobinex

If you could, yes please, I got as far as that it starts compiling but fails on: 0024:err:module:import_dll Library libwinpthread-1.dll Which doesn't make sense to me as there is https://github.com/dkfans/keeperfx/pull/1018

zaggynl avatar Dec 23 '23 15:12 zaggynl

I don't know why you still get that error, I'll ask around, but here is the file you asked for: keeperfx.devbuild.debug.3695.zip

Be sure to download and install alpha 3695 first.

Loobinex avatar Dec 23 '23 16:12 Loobinex

0024:err:module:import_dll Library libwinpthread-1.dll

Hi @zaggynl What were you using to compile?

eddebaby avatar Dec 23 '23 18:12 eddebaby

I don't know why you still get that error, I'll ask around, but here is the file you asked for: keeperfx.devbuild.debug.3695.zip

Be sure to download and install alpha 3695 first.

Thanks, this is working, will report back with log file once I get a hang.

0024:err:module:import_dll Library libwinpthread-1.dll

Hi @zaggynl What were you using to compile?

vscode RPM from https://code.visualstudio.com/download# on opensuse tumbleweed.

zaggynl avatar Dec 23 '23 22:12 zaggynl

I am not familiar with opensuse, but I did a quick internet search to see if I could see anything interesting.

This might be what you need: https://github.com/godotengine/godot/issues/10387 (i.e. it seems you need special cross-compile versions of mingw to be able to compile a windows exe in opensuse).

eddebaby avatar Dec 23 '23 23:12 eddebaby

keeperfx.log

Funny enough, if I play using the keeperfx_hvlog.exe binary I don't get any crashes.

zaggynl avatar Dec 29 '23 13:12 zaggynl

FWIW, after updating Wine to 8.21-2 (Arch Linux) the crashes are gone... I've been playing 5+ hours and everything works.

Now I'm like 20+ hours of playing and no crashes. @zaggynl, @phoe what versions of Wine, kernel, Mesa are you using?

madmanxxx avatar Dec 29 '23 13:12 madmanxxx

GL_VERSION = 4.6 (Compatibility Profile) Mesa 23.3.1-3 wine-9.0-rc2 Linux helix 6.5.0-5-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.13-1 (2023-11-29) x86_64 GNU/Linux

phoe avatar Dec 29 '23 13:12 phoe

keeperfx.log

Funny enough, if I play using the keeperfx_hvlog.exe binary I don't get any crashes.

Unfortunately I don't think the log shows anything useful,...

Loobinex avatar Dec 29 '23 14:12 Loobinex