-
Notifications
You must be signed in to change notification settings - Fork 793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug on Windows: game crashes when the PC wakes up from sleep #688
base: master
Are you sure you want to change the base?
Conversation
Congratulations 🎉. DeepCode analyzed your code in 1.109 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard |
Interesting, ill try and find a laptop to test on :) |
I don't currently have a desktop PC, but I suppose you can get the same effect there by pressing the power button during the game, to send the PC to sleep. |
I was unable to replicate this both on Linux, and windows 10. Could you give some specs for you machine and sdl version your using? |
Fujitsu Lifebook E752, Windows 10 ver. 1909, SDL 2.0.10: https://youtu.be/obSPmm1D580 (sorry for the shaky phone!) |
Looks like it's an Intel GPU, the Windows machine I tested on had an AMD GPU. I do have a machine with an Intel GPU, but it doesn't have Windows installed. Could you try SDL 2.0.12? |
Yes, it's Intel HD Graphics 4000
Still the same :-( |
SourceX/dx.cpp
Outdated
@@ -261,7 +261,31 @@ void RenderPresent() | |||
#ifndef USE_SDL1 | |||
if (renderer) { | |||
if (SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch) <= -1) { //pitch is 2560 | |||
ErrSdl(); | |||
// We should supposedly handle SDL_RENDER_DEVICE_RESET, but I tried and it doesn't arrive | |||
if (!strcmp(SDL_GetError(), "LockRect(): INVALIDCALL")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this could be detected similar to what was done with GetOutputSurface based on the state of the texture. could you check the state of SDL_WasInit() and see what returns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0xe231
which is the same value as passed to SDL_Init
I guess that only the texture(s) get invalidated by the sleep, not the whole of SDL.
Will it help if I upload a dump file, stopped at a breakpoint after the sleep, with the texture invalidated? |
@tyomitch could you test to see if this issue is still present. We are having trouble reproducing it. |
Yes, the same, except that the failing assertion is now at "....\Source\dx.cpp line 313" |
SourceX/dx.cpp
Outdated
@@ -261,7 +261,31 @@ void RenderPresent() | |||
#ifndef USE_SDL1 | |||
if (renderer) { | |||
if (SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch) <= -1) { //pitch is 2560 | |||
ErrSdl(); | |||
// We should supposedly handle SDL_RENDER_DEVICE_RESET, but I tried and it doesn't arrive | |||
if (!strcmp(SDL_GetError(), "LockRect(): INVALIDCALL")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!strcmp(SDL_GetError(), "LockRect(): INVALIDCALL")) { | |
if (string_view(SDL_GetError()) == "LockRect(): INVALIDCALL") { |
SourceX/dx.cpp
Outdated
// We should supposedly handle SDL_RENDER_DEVICE_RESET, but I tried and it doesn't arrive | ||
if (!strcmp(SDL_GetError(), "LockRect(): INVALIDCALL")) { | ||
SDL_DestroyTexture(texture); | ||
SDL_DestroyRenderer(renderer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd probably be a good idea to extract this to a function and also handle SDL_RENDER_DEVICE_RESET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be in UiHandleEvents()
in DiabloUI/diabloui.cpp right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UiHandleEvents()
runs during the main menu, but in-game it is FetchMessage_Real()
in Source/miniwin/misc_msg.cpp
If I close and reopen my laptop during the game, it crashes with > SDL Error > LockRect(): INVALIDCALL > The error occurred at: ..\..\Source\dx.cpp line 313
Also, handle `SDL_RENDER_DEVICE_RESET`
If I close and reopen my laptop during the game, it crashes with
I have absolutely no experience with SDL, but I've managed to put
together a workaround. Improvements are welcome.