Skip to content
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

Crash when moving window to another screen when per-pixel-transparency is enabled #23446

Closed
lekoder opened this issue Nov 2, 2018 · 6 comments

Comments

@lekoder
Copy link
Contributor

lekoder commented Nov 2, 2018

Godot version:
3.1 0dbe014

OS/device including version:
Windows 10

Issue description:
When per-pixel transparency is enabled, if you try to move the window to another monitor (screen) and enable fullscreen, the game will crash.

Steps to reproduce:

  1. Enable per-pixel transparency for project
  2. In _ready of the scene move window position to second screen, resize it to it and enable fullscreen.

Expected result: scene is displayed
Actual result: splash screen is displayed, application is unresponsive. No way to connect with debugger.

Minimal reproduction project:
Github repo. Requires two monitors.

Notes:
This problem surfaced suddenly in both new projects and old ones (including Steam-published binaries). Probably related to recent Windows update.

Workaround:
If I disable per-pixel transparency trough code, wait a frame and then move the screen - everything works. If you try to disable the transparency and move screen immediately it still crashes (with blank screen).

@lekoder
Copy link
Contributor Author

lekoder commented Nov 2, 2018

Also affects c025f52

@akien-mga
Copy link
Member

CC @bruvzg

@bruvzg
Copy link
Member

bruvzg commented Nov 2, 2018

I was not able to reproduce it on my machine - Windows 10, version 1809 (build 10.0.17763.55), AMD FirePro D300, Adrenalin 18.10.2 (18.40.07.01-181019a) driver. I'll test it a bit later on another machine with NVIDIA and Intel GPUs.

Problem may be caused by incompatible display caps (I have two identical displays), or it's driver specific.

@lekoder could you try it with following patch?

diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index f8705c4bf..9b43c8139 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -738,6 +738,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 			}
 		} break;
 
+		case WM_DISPLAYCHANGE:
 		case WM_SIZE: {
 			int window_w = LOWORD(lParam);
 			int window_h = HIWORD(lParam);
@@ -760,6 +761,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 			}
 			if (is_layered_allowed() && layered_window) {
 				DeleteObject(hBitmap);
+				DeleteDC(hDC_dib);
+
+				hDC_dib = CreateCompatibleDC(GetDC(hWnd));
 
 				RECT r;
 				GetWindowRect(hWnd, &r);

@lekoder
Copy link
Contributor Author

lekoder commented Nov 2, 2018

@bruvzg It got fixed after installing KB4462933 OS Build 17134.376 which bumped my build to Windows 10 Pro v1803 17134.376 - before I had a chance to test the patch.

@lekoder
Copy link
Contributor Author

lekoder commented Nov 2, 2018

KB4462933 also fixed #22463 for me.

@akien-mga
Copy link
Member

Given that a system update fixed it, I guess we can close it.

@bruvzg I'll let you see if you think the proposed patch is still good to merge to be safe, or if the current state is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants