Skip to content

[Linux] Add FLUTTER_LINUX_RENDERER=opengl-gtk to opt out of the Wayland subsurface - #196530

Open
kekko7072 wants to merge 1 commit into
flutter:masterfrom
kekko7072:linux-renderer-opengl-gtk
Open

kekko7072 wants to merge 1 commit into
flutter:masterfrom
kekko7072:linux-renderer-opengl-gtk

Conversation

@kekko7072

@kekko7072 kekko7072 commented Nov 13, 2026 •

Copy link
Copy Markdown

On Wayland, FlView always presents OpenGL frames through FlViewRendererSubsurface (added in 3.50). With that renderer, some setups freeze at startup or show a black window (#196529, #195822). The only way to get the GTK path (FlViewRendererOpenGL) back is GDK_BACKEND=x11.

This adds an opengl-gtk value to the existing FLUTTER_LINUX_RENDERER environment variable. It keeps the OpenGL renderer but presents through GTK, as on X11. Nothing changes when the variable is unset, opengl or software.

  • fl_engine.cc / fl_engine_private.h: new fl_engine_get_use_subsurface(), TRUE unless FLUTTER_LINUX_RENDERER=opengl-gtk.
  • fl_view.cc: uses FlViewRendererSubsurface only when that is TRUE and the display is Wayland.
  • fl_engine_test.cc: RendererDefault and RendererOpenGLGtk.

I have not run the engine tests locally yet. clang-format reports no changes on the modified lines.

Part of #196529: an opt-out while the subsurface issue is investigated. It does not fix the underlying bug, and doesn't fix #195822 either.

No changes to flutter/tests.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

…nd subsurface

On Wayland, FlView always presents OpenGL frames through
FlViewRendererSubsurface. Some setups freeze or render black with it
(see flutter#196529, flutter#195822), and there is no way to opt out short of
GDK_BACKEND=x11.

Add an "opengl-gtk" value for FLUTTER_LINUX_RENDERER that keeps the
OpenGL renderer but presents through GTK (FlViewRendererOpenGL), as on
X11. The default is unchanged.
@google-cla

google-cla Bot commented Nov 13, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically a: desktop Running on desktop team-linux Owned by the Linux platform team labels Nov 13, 2026
@kekko7072
kekko7072 marked this pull request as ready for review November 13, 2026 15:33
@kekko7072
kekko7072 requested a review from a team as a code owner November 13, 2026 15:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a use_subsurface configuration to FlEngine to control whether OpenGL frames are presented via a Wayland subsurface or through GTK (when FLUTTER_LINUX_RENDERER is set to opengl-gtk). The feedback suggests explicitly initializing renderer_type to kOpenGL to avoid relying on zero-initialization, and refactoring the RendererDefault test to isolate it from host environment variables.


self->project = FL_DART_PROJECT(g_object_ref(project));
const gchar* renderer = g_getenv("FLUTTER_LINUX_RENDERER");
self->use_subsurface = TRUE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Relying on zero-initialization for the default renderer_type enum value is fragile. If the enum values are reordered or a new default is introduced, this could break silently. Explicitly initializing self->renderer_type to kOpenGL alongside self->use_subsurface improves safety and maintainability.

  self->renderer_type = kOpenGL;
  self->use_subsurface = TRUE;

Comment on lines +1210 to +1213
TEST_F(FlEngineTest, RendererDefault) {
EXPECT_EQ(fl_engine_get_renderer_type(engine), kOpenGL);
EXPECT_TRUE(fl_engine_get_use_subsurface(engine));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The RendererDefault test uses the shared engine instance from the test fixture, which is initialized during SetUp(). If the host environment running the tests has the FLUTTER_LINUX_RENDERER environment variable set (e.g., to software or opengl-gtk), this test will fail. To make the test robust against the host environment, it should use a locally created engine with FLUTTER_LINUX_RENDERER explicitly unset (and restored afterwards).

TEST_F(FlEngineTest, RendererDefault) {
  g_autofree gchar* initial_renderer =
      g_strdup(g_getenv("FLUTTER_LINUX_RENDERER"));
  g_unsetenv("FLUTTER_LINUX_RENDERER");

  g_autoptr(FlDartProject) project = fl_dart_project_new();
  g_autoptr(FlEngine) default_engine = fl_engine_new(project);
  EXPECT_EQ(fl_engine_get_renderer_type(default_engine), kOpenGL);
  EXPECT_TRUE(fl_engine_get_use_subsurface(default_engine));

  if (initial_renderer != nullptr) {
    g_setenv("FLUTTER_LINUX_RENDERER", initial_renderer, TRUE);
  } else {
    g_unsetenv("FLUTTER_LINUX_RENDERER");
  }
}

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

Labels

a: desktop Running on desktop engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team

Projects

None yet

1 participant