- Loading...
XWayland server provides limited capabilities for X11 desktop applications (see X11 Application Support and JDK-8269245). In order to get full support of the desktop features, we need to implement a pure Wayland client toolkit for java. Wayland architecture in many ways differs from X11, so we cannot reuse XAWT even for basic capabilities. The new toolkit should be implemented from scratch. Here are some major chunks of work:
Event handling
Dispatch native events on EDT, to avoid potential race conditions when the state is updated both from EDT and toolkit thread. See the full proposal here
Graphics devices support
Onscreen/offscreen Wayland surface management
Adopt OGL pipeline for rendering on Wayland surfaces
Implement a new rendering pipeline based on Vulkan (for better performance)
java.awt.Robot
Sending input events
Reading screen data (at least current java application windows)
Client-side decorations for windows
Swing internal frames rendering code can be reused
The prototype implementation of the pure Wayland toolkit (JDK-8281970) based on OpneJDK 25 source base can be found in the Wakefield repository (pure_wl_toolkit jdk25-wayland branch). It uses software rendering loops to draw geometry primitives on Wayland surfaces. It supports the rendering of AWT Frame and Swing JFrame.has two rendering pipelines:
Most of the graphics primitives are supported in hardware-accelerated rendering, so it's possible to run Swing applications on top of it.
java -Dawt.toolkit.name=WLToolkit JFTest-Dsun.java2d.vulkan=True -jar SwingSet2.jar
The java.awt.Robot
functionality is implemented in a somewhat roundabout way because it contradicts several basic principles of Wayland such as not exposing pixels after they have been composited. As a short- to mid-term solution, we intend to run tests in an instance of Weston (one such instance per test) that runs on top of X11. That instance of Weston requires a custom plugin libwakefield.so
(source code is under src/java.desktop/share/native/libwakefield). A Java wrapper is available that helps to fire up and tear down Weston and set up WAYLAND_DISPLAY
for the test. There is also a sample test test/jdk/java/awt/wakefield/ScreenCapture.java that can be run roughly as follows:
export LIBWAKEFIELD=/.../build/wakefield/libwakefield.so
jtreg -e:XDG_RUNTIME_DIR -e:LIBWAKEFIELD -testjdk:... test/jdk/java/awt/wakefield/
This was verified to work with Weston 9 on Ubuntu 21.10.
Text rendering has been implemented (JDK-8281970)
Here is an updated build instruction for building jdk25-wayland branch (on ubunu 24.04). You need to have at least JDK24 for bootstrapping:
$ sudo wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | tee /etc/apt/trusted.gpg.d/lunarg.asc
$ sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-noble.list https://packages.lunarg.com/vulkan/lunarg-vulkan-noble.list
$ sudo apt update
$ sudo apt-get -y install file zip unzip autoconf make build-essential libx11-dev libxext-dev libxrender-dev \
libxtst-dev libxt-dev libxrandr-dev libcups2-dev libfontconfig1-dev libasound2-dev libwayland-dev \
libxkbcommon-x11-0 vulkan-sdk vulkan-utility-libraries-dev
$ sh configure --with-vulkan
$ make images
Here are some performance resuls with RenderPerfTest:
java
...
-Dawt.toolkit.name=WLToolkit
...
Also, WLToolkit
now has support for
...
-Dsun.java2d.vulkan=True -jar ./dist/RenderPerfTest.jar
Vulkan rendering enabled: YES
Presentation enabled: YES
Accelerated surface data enabled: YES
Devices:
*0: AMD Radeon RX 6800 XT (RADV NAVI21)
1: llvmpipe (LLVM 19.1.1, 256 bits)
# Using GraphicsConfiguration(s): [0-0][WLVKGraphicsConfig[B8G8R8A8_UNORM, AMD Radeon RX 6800 XT (RADV NAVI21) (DISCRETE_GPU), LEN LEN T27p-10]]
Test Name | Median(FPS) ± Stddev(FPS) Unit |
---|---|
ArgbSurfaceBlitImage | 51.736 ± 4.660 |
ClipFlatBox | 800.932 ± 18.898 |
ClipFlatOval | 283.220 ± 26.588 |
FlatBox | 812.571 ± 24.375 FPS |
FlatBoxAA | 811.514 ± 24.884 |
FlatOval | 130.565 ± 2.435 |
FlatOvalAA | 48.687 ± 0.452 |
FlatQuad | 78.028 ± 1.543 |
FlatQuadAA | 21.878 ± 0.158 |
Image | 48.417 ± 1.658 |
ImageAA | 48.626 ± 5.408 |
LargeTextGray | 824.941 ± 5.569 |
LinGrad3RotatedOval | 0.174 ± 0.002 |
LinGrad3RotatedOvalAA | 49.496 ± 0.769 |
LinGradRotatedOval | 213.821 ± 8.662 |
LinGradRotatedOvalAA | 48.601 ± 0.367 |
TextGray | 162.329 ± 1.553 |
VolImage | 818.628 ± 12.465 |
WiredBubbles | 105.454 ± 3.160 |
...