etternagame / etterna

Advanced cross-platform rhythm game focused on keyboard play
https://etternaonline.com/
MIT License
475 stars 134 forks source link

g_pd3dDevice->Reset failed. #1166

Closed thiccyoshi4568 closed 2 years ago

thiccyoshi4568 commented 2 years ago

Alright so, I was playing some Etterna, played a song, had dinner, came back, and this error was here. I don't know what happened. image

thiccyoshi4568 commented 2 years ago

Error log: 2022_05_14-17_42_04.log

nico-abram commented 2 years ago

Since the log error message is empty, it's kinda hard to know what happened. Here's a random guess though:

From the ::Reset documentation https://docs.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-reset :

Before calling the IDirect3DDevice9::Reset method for a device, an application should release any explicit render targets, depth stencil surfaces, additional swap chains, state blocks, and D3DPOOL_DEFAULT resources associated with the device.

Looking around the only place where we call ->Reset, it seems we are deleting render targets after calling Reset, instead of before:

https://github.com/etternagame/etterna/blob/201115635bb3635ca5f3e65c395e55ba7c1b5300/src/RageUtil/Graphics/RageDisplay_D3D.cpp#L403-L417

Regarding the empty error message, it seems to have been hardcoded to that in this commit https://github.com/etternagame/etterna/commit/cae27008098c6ceea0c85b8f344f679f81a79a92 as part of - Removing dxerr.h includes (see https://walbourn.github.io/wheres-dxerr-lib/ ), Fixing the error message would probably mean using FormatMessage the way that blog post describes, although that won't work on windows versions older than 8 (But hopefully it won't fail catastrophically?).

https://github.com/etternagame/etterna/blob/201115635bb3635ca5f3e65c395e55ba7c1b5300/src/RageUtil/Graphics/RageDisplay_D3D.cpp#L32

nico-abram commented 2 years ago

Forgot to mention: As a stopgap fix, using opengl shouldn't have this issue

nico-abram commented 2 years ago

I was able to get the same crash message by going into the selectmusic screen in til death and changing between fullscreen and windowed via alt+enter . Not 100% sure if it's the same crash since there's no message but I bet it is. Now that I can repro I can test my theory from above

nico-abram commented 2 years ago

I think this issue might be a duplicate of https://github.com/etternagame/etterna/issues/953 ?

@thiccyoshi4568 what etterna version are you on?

thiccyoshi4568 commented 2 years ago

I'm on 0.71.2 Rebirth.

nico-abram commented 2 years ago

Weird, I think all uses of the thing that crashes (ActorFrameTexture) have been removed from til death/rebirth. Either way, this should be fixed by https://github.com/etternagame/etterna/pull/1167 , unless I completely misunderstood what the problem was. It's possible it was a different error (Like D3DERR_DEVICELOST). https://github.com/etternagame/etterna/pull/1168 should improve the error message. So this should be fixed whenever we make a new release, and if not, at least the logs should include a bit more info.

For now, if this continues to be a problem, just switch to opengl. I'm gonna close this for now.