Skip to content

Screenshots on Wayland are always white [Snippet215] #673

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

Open
DieterMaiSysgo opened this issue May 16, 2023 · 4 comments
Open

Screenshots on Wayland are always white [Snippet215] #673

DieterMaiSysgo opened this issue May 16, 2023 · 4 comments
Labels
Linux/GTK Happens on Linux Wayland

Comments

@DieterMaiSysgo
Copy link

DieterMaiSysgo commented May 16, 2023

Describe the bug
When creating a screenshot as described by Snippet215, the resulting image is all white. I would expect that the image instead contains a content reflecting the pixels displayed when the screenshot was taken.

To Reproduce
Easiest would be to execute Snippet215 on Ubuntu 22.
But essentially the following code seems not to work

	GC gc = new GC(display);
	Rectangle bounds = display.getBounds();
	final Image image = new Image(display, display.getBounds());
	gc.copyArea(image, 0, 0);

Expected behavior
I would expect to be able to create an screenshot with SWT. Preferably as demonstrated in Snippet215

Screenshots
SWT screenshot issue

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    I tested this on Windows 10, Ubuntu 20 and Ubuntu 22. Only Ubuntu 22 has this issue.

  2. JRE/JDK version
    Tested with JDK 17

Version since
Tested with 4.26 and 4.27. Both had the same issue

Workaround (or) Additional context
I was not able to find a workaround.
I found this issue while investigating why our SWTBot test does not produce any screenshots. SWTBot uses SWT to create screenshot in a similar way as Snippet215

Kind regards
Dieter Mai

@iloveeclipse
Copy link
Member

iloveeclipse commented May 16, 2023

  • Which GTK3 version is used?
  • Are you on Wayland? If yes, please try with X11.
  • Please try with Eclipse 4.27. 4.16/4.17 are too old.

@DieterMaiSysgo
Copy link
Author

  • Which GTK3 version is used?
$ dpkg -l libgtk-3-0
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version          Architecture Description
+++-================-================-============-====================================
ii  libgtk-3-0:amd64 3.24.33-1ubuntu2 amd64        GTK graphical user interface library
  • Are you on Wayland? If yes, please try with X11.

The issue seems to be connected to wayland. When is login with "Ubuntu on xorg" the issue no longer occurs.

  • Please try with Eclipse 4.27. 4.16/4.17 are too old.

I named the SWT libs wrongly and and when wrote the ticket i copied the mistake. Correct is: I tested this with SWT 4.26 and 4.27. Sorry for the confusion.

While the switch from Wayland to X works, this issue is not solved by this.

Kind regards
Dieter

@iloveeclipse iloveeclipse added Linux/GTK Happens on Linux Wayland labels May 16, 2023
@iloveeclipse iloveeclipse changed the title Screenshots on Ubuntu 22 are always white [Snippet215] Screenshots on Wayland are always white [Snippet215] May 16, 2023
@basilevs
Copy link
Contributor

basilevs commented Mar 25, 2025

Workaround

On SWT 3.129, GTK 3.24.41, using X11, screenshots taken with this method are always the same as the first taken screenshot.

In other words, the state of screen is captured once and can never be updated. I assume, that you are capturing right before actual rendering happens, and then try again later. Try to only capture the last shot.

@HeikoKlare
Copy link
Contributor

On SWT 3.129, GTK 3.24.41, using X11, screenshots taken with this method are always the same as the first taken screenshot.

This issue has already been fixed:

With current I-Builds, screenshots will capture the current state again (when using X11).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linux/GTK Happens on Linux Wayland
Projects
None yet
Development

No branches or pull requests

4 participants