Click here to Skip to main content
14,974,268 members
Articles / Desktop Programming / X11
Tip/Trick
Posted 26 Apr 2021

Tagged as

Stats

5K views

Configuring Ubuntu 21.04 for Wayland and Flutter Desktop

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
14 Jun 2021CPOL3 min read
Moving from X11 with NVIDIA drivers to Wayland may require more configuration
Wayland will be disabled if NVIDIA graphics drivers are detected.

Ubuntu 21.04 Touts Flutter and Wayland

On April 22nd, Ubuntu 21.04 was announced with some hype around delivering "Wayland and Flutter for smoother graphics and clean, beautiful, design-led cross-platform development." As I use Flutter 2.0 regularly, including Flutter on the desktop, I decided to upgrade my Ubuntu 20.04 workstation to 21.04 with do_release_upgrade -d. Most people shouldn't have to add the -d for the development release. Please try it first without the -d. Although I did the upgrade on April 25, after 21.04 was publicly available, I needed to add the -d on my system.

I first upgraded to 20.10, then upgraded to 21.04. Although it took a while to upgrade all the different components, the upgrade went fine.

Problems Switching to Wayland

Although I could log into gdm3, it looked like I was using x11 and not Wayland.

$ echo $XDG_SESSION_TYPE

would return x11, not the expected wayland.

Additionally, I would not get the gear icon on the login screen to choose between the Ubuntu Wayland and X.org. On 21.04, it seems like Wayland is default and just called ubuntu on the gear of the login screen. After my upgrade, the gear did not even appear.

Fixing the Problem

gdm3 custom.conf

Initially, I thought I could fix the problem by modifying /etc/gdm3/custom.conf.

There is a nice comment that sources like commenting out WaylandEnable=false will cause Wayland to be enabled.

# GDM configuration storage
#
# See /usr/share/gdm/gdm.schemas for a list of available options.

[daemon]
# Uncomment the line below to force the login screen to use Xorg
# WaylandEnable=false

# Enabling automatic login
#  AutomaticLoginEnable = true
#  AutomaticLogin = user1

After commenting out WaylandEnable=false, I rebooted my computer, but I still did not get Wayland to work.

gdm udev rules

Even after I purged all my nvidia driver files, I was still not able to enable Wayland. I then edited /usr/lib/udev/rules.d/61-gdm.rules and commented out the check for DRIVER=="nvidia".

cd /usr/lib/udev/rules.d/

$ sudo vi 61-gdm.rules

# disable Wayland on Hi1710 chipsets
ATTR{vendor}=="0x19e5", ATTR{device}=="0x1711", RUN+="/usr/libexec/gdm-disable-wayland"

# disable Wayland when using the proprietary nvidia driver
# DRIVER=="nvidia", RUN+="/usr/libexec/gdm-disable-wayland"

# disable Wayland if modesetting is disabled
IMPORT{cmdline}="nomodeset", RUN+="/usr/libexec/gdm-disable-wayland"

After rebooting the system, I was able to change into Wayland.

Now, checking on the XDG_SESSION_TYPE shows wayland as expected.

Testing Flutter Desktop

My whole goal of enabling Wayland was to test Flutter desktop as touted by Canonical CEO Mark Shuttleworth in the Ubuntu 21.04 announcement.

I created a sample project called desk. I used the automated dart migrate command to start using Dart 2.12.0 with sound null safety for Flutter 2.0.

$ flutter create --platforms=linux desk
cd desk
dart migrate --apply-changes 
flutter run

The default desktop app runs great on Linux.

I next tested a more complex app for the RICOH THETA 360 camera that I had originally built on Windows.

The app uses 23MP 360 degree images that are around 8MB in size. The app runs and the 360 image can be navigated. However, the graphics performance feels marginally smoother on Windows 10.

I'm running an NVIDIA GTX 950Ti with X.org driver and an Intel i7-6800K CPU.

The NVIDIA 470 Linux driver is supposed to have more Wayland support. However, it's not available right now. I did not test the 465.31 version released on May 18, 2021.

 

OBS Screen Sharing

OBS 27 released in early June 2021 adds support for Wayland screen capture. The test below was done with OBS 27.0.1, released June 11, 2021. 

obs screenshot

The screen capture should use PipeWire.

Image 2

 

 

Summary

Building Flutter Linux desktop apps works with Wayland. However, I can't see any performance or graphic gains initially. I intend to keep using Wayland with Flutter and plan to keep an eye on the status of the NVIDIA drivers for future hardware acceleration improvements.

 

History

  • 27th April, 2021: Initial version
  • 14 June, 2021: Added information on OBS 27

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Cloudster
United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --