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

[Bug]: Full Screen Transparent Windows are White on Windows 10 #30798

Closed
3 tasks done
carterbs opened this issue Sep 1, 2021 · 4 comments · Fixed by #30804
Closed
3 tasks done

[Bug]: Full Screen Transparent Windows are White on Windows 10 #30798

carterbs opened this issue Sep 1, 2021 · 4 comments · Fixed by #30804
Assignees
Labels
12-x-y 13-x-y 14-x-y 15-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@carterbs
Copy link
Contributor

carterbs commented Sep 1, 2021

Preflight Checklist

Electron Version

14.0.0

What operating system are you using?

Windows

Operating System Version

Windows 10 Pro version 20H2, OS build 19042.1110

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

A transparent window should be transparent, no matter its height or width.

Actual Behavior

BROKEN

GIVEN your window is transparent, frameless, and you are running on windows
AND your window's width === monitor width and the window's height === monitor height
AND its top left corner is the top left corner of your monitor
THEN your transparent window will be white and render nothing

GIVEN prereqs above
AND your window's width === monitor width - 1 and the window's height === monitor height
AND its top left corner is the top left corner of your monitor
THEN your transparent window will be white and render nothing

GIVEN prereqs above
AND your window's width === monitor width and the window's height === monitor height
AND its top left corner is the top left corner of your monitor
THEN your transparent window will be white and render nothing

WORKS
GIVEN prereqs above
AND your window's width === monitor width and the window's height === monitor height
AND its top left corner is the top left corner of your monitor + 1 px in the X or Y direction
THEN your transparent window will be transparent and perfect

GIVEN prereqs above
AND your window's width === monitor width - 1 and the window's height === monitor height - 1
AND its top left corner is the top left corner of your monitor
THEN your transparent window will be transparent and perfect

Testcase Gist URL

https://gist.github.com/d52ceca16461bfe12b2bf936bc462412

Additional Information

If you shift the top left corner of the window by 1 pixel, the bug goes away. I assume there's a falsey check somewhere and 0 is triggering it. I didn't test this on a secondary monitor.

@carterbs carterbs changed the title [Bug]: Full Screen Transparent Windows are White [Bug]: Full Screen Transparent Windows are White on Windows 10 Sep 1, 2021
@samuelmaddock samuelmaddock added 12-x-y 13-x-y 14-x-y 15-x-y has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature labels Sep 1, 2021
@samuelmaddock
Copy link
Member

Confirmed that I can reproduce this issue on Windows 10 21H1 build 19043.1165

I forked your gist to automatically get the primary display's width/height: https://gist.github.com/817c57f1aaffece3cae795bba640f829

@carterbs
Copy link
Contributor Author

carterbs commented Sep 1, 2021

Confirmed that I can reproduce this issue on Windows 10 21H1 build 19043.1165

I forked your gist to automatically get the primary display's width/height: https://gist.github.com/817c57f1aaffece3cae795bba640f829

Gracias. Didn't take the time to do that - appreciate it.

@samuelmaddock samuelmaddock self-assigned this Sep 1, 2021
@samuelmaddock
Copy link
Member

This happens only when the BrowserWindow is shown within the first tick after its creation when the size matches the primary display's size.

Calling Show() attempts to get the window's restore state in GetRestoredState().

void NativeWindowViews::Show() {
if (is_modal() && NativeWindow::parent() &&
!widget()->native_widget_private()->IsVisible())
static_cast<NativeWindowViews*>(parent())->IncrementChildModals();
widget()->native_widget_private()->Show(GetRestoredState(), gfx::Rect());

ui::WindowShowState NativeWindowViews::GetRestoredState() {
if (IsMaximized())
return ui::SHOW_STATE_MAXIMIZED;
if (IsFullscreen())
return ui::SHOW_STATE_FULLSCREEN;
return ui::SHOW_STATE_NORMAL;
}

It ends up using the ui::SHOW_STATE_MAXIMIZED restore state since it's a transparent window and its bounds match that of the display.

bool NativeWindowViews::IsMaximized() {
if (widget()->IsMaximized()) {
return true;
} else {
#if defined(OS_WIN)
if (transparent()) {
// Compare the size of the window with the size of the display
auto display = display::Screen::GetScreen()->GetDisplayNearestWindow(
GetNativeWindow());
// Maximized if the window is the same dimensions and placement as the
// display
return GetBounds() == display.work_area();
}
#endif

Restoring the maximized state causes problems in Chromium code: https://source.chromium.org/chromium/chromium/src/+/main:ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc;l=342-351;drc=11aaa9f9150091c805928724c83d8a807cb65faf

A temporary workaround is to delay showing the BrowserWindow until either the ready-to-show event or delaying by one tick.

@carterbs
Copy link
Contributor Author

carterbs commented Sep 2, 2021

I gave both of those a try with hardware acc disabled, and the window just never rendered. Even if it did render eventually, (and I'm just doing something wrong), I worry that it'd butt up against this bug (#27265). The +1 trick is very dirty but it won't prevent me from deploying my feature, so I'm going to roll with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
12-x-y 13-x-y 14-x-y 15-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants