Skip to content

Split FlViewRenderer into OpenGL and software backends#188824

Merged
robert-ancell merged 13 commits into
flutter:masterfrom
robert-ancell:linux-split-view-renderer
Jul 8, 2026
Merged

Split FlViewRenderer into OpenGL and software backends#188824
robert-ancell merged 13 commits into
flutter:masterfrom
robert-ancell:linux-split-view-renderer

Conversation

@robert-ancell

Copy link
Copy Markdown
Contributor

No description provided.

Split FlViewRenderer into a minimal abstract base class with two
self-contained backend subclasses, FlViewRendererOpenGL and
FlViewRendererSoftware. Each subclass owns its own state and compositor
and implements rendering for its backend. fl_view.cc selects which
subclass to create based on the engine's renderer type.
Make FlCompositorOpenGL and FlCompositorSoftware derive directly from
GObject and expose their present_layers, get_frame_size and render
functions as public concrete functions. The view renderers and
compositor tests now call these directly, removing the need for the
FlCompositor base class, which is deleted.
Make FlCompositorSoftware pure frame storage/combining by moving the
frame_mutex and task_runner into FlViewRendererSoftware. The renderer now
owns the synchronization: it locks around compositor access, signals the
task runner after presenting, and runs the resize wait loop in draw.
Make FlCompositorOpenGL pure frame storage/combining by moving the
frame_mutex and task_runner into FlViewRendererOpenGL. The renderer now
owns the synchronization: it locks around compositor access, signals the
task runner after presenting, and runs the resize wait loop in draw.
Extract the wait-for-frame loop in the software and OpenGL view renderers
into a dedicated static function to improve readability.
@robert-ancell robert-ancell requested a review from a team as a code owner July 1, 2026 02:31
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 1, 2026
@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 Jul 1, 2026
@robert-ancell robert-ancell requested a review from mattkae July 1, 2026 02:31
@robert-ancell

Copy link
Copy Markdown
Contributor Author

Split out of #188767

@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 refactors the Linux platform rendering architecture by removing the abstract FlCompositor class and splitting FlViewRenderer into a derivable base class with concrete subclasses FlViewRendererOpenGL and FlViewRendererSoftware. The concrete compositors FlCompositorOpenGL and FlCompositorSoftware now inherit directly from GObject. A high-severity issue was identified in fl_view_renderer_software.cc where the compositor is cleared in dispose() instead of finalize(), which violates the design intended to keep the compositor alive for the raster thread during a forced dispose.

Replace the scoped GMutexLocker in present_layers with explicit
g_mutex_lock/g_mutex_unlock calls for consistency with the rest of the
view renderer code.
Rename fl_compositor_opengl_present_layers to
fl_compositor_opengl_composite_layers and
fl_compositor_software_present_layers to
fl_compositor_software_composite_layers, updating all callers and tests.
Describe where each compositor stores its composited frame (an OpenGL
framebuffer texture for the OpenGL compositor, a Cairo image surface for
the software compositor) and, for the OpenGL compositor, how OpenGL
contexts are used when a frame is written by one context and read by
another (shared context group with a glFlush, or a CPU copy when not
shareable).

@mattkae mattkae 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.

Some minor questions about sharing possibilities 🤔

Comment thread engine/src/flutter/shell/platform/linux/fl_view_renderer.cc Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_compositor_opengl.h Outdated
Comment thread engine/src/flutter/shell/platform/linux/fl_view_renderer_software.cc Outdated
Give present_layers a default implementation that asserts it is not
reached, so subclasses must override it. This removes the need to
null-check the vfunc pointer before calling it.
Move the have_first_frame flag into the FlViewRenderer base class and add
fl_view_renderer_notify_frame, which subclasses call on each frame. The
base class emits the first-frame signal on the first call.
@robert-ancell robert-ancell requested a review from mattkae July 2, 2026 01:32
@robert-ancell

Copy link
Copy Markdown
Contributor Author

I've attempted to chain some changes here once this lands we can look at robert-ancell#1 and then robert-ancell#2. Not sure if GitHub will move these PRs here if not I'll open new ones.

@robert-ancell robert-ancell enabled auto-merge July 6, 2026 00:34
@robert-ancell robert-ancell disabled auto-merge July 6, 2026 00:34
@robert-ancell robert-ancell enabled auto-merge July 8, 2026 21:10
@robert-ancell robert-ancell added this pull request to the merge queue Jul 8, 2026
Merged via the queue into flutter:master with commit fee1f02 Jul 8, 2026
197 checks passed
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jul 10, 2026
…12169)

Manual roll Flutter from 91939cc4db78 to dc2a8703e12b (50 revisions)

Manual roll requested by bensonluk@google.com

flutter/flutter@91939cc...dc2a870

2026-07-09 chris@bracken.jp [ios,macos] Update swiftc.py flags to match swiftc (flutter/flutter#189174)
2026-07-09 jesswon@google.com [AGP 9] Update Warn Version to AGP 9+ (flutter/flutter#189109)
2026-07-09 154381524+flutteractionsbot@users.noreply.github.com Sync CHANGELOG.md from stable (flutter/flutter#189203)
2026-07-09 mdebbar@google.com [web] Roll Chrome to 145 (framework) (flutter/flutter#182861)
2026-07-09 engine-flutter-autoroll@skia.org Roll Packages from 52d84d6 to 20928d5 (6 revisions) (flutter/flutter#189194)
2026-07-09 zhongliu88889@gmail.com [web] Avoid absolute positioning for base CanvasKit canvas (flutter/flutter#188337)
2026-07-09 engine-flutter-autoroll@skia.org Roll Dart SDK from cdb7217e65aa to a11fb7ed40a5 (6 revisions) (flutter/flutter#189195)
2026-07-09 matt.kosarek@canonical.com Fix dereference of nullptr in the moved-to-rect signal in the Linux embedder (flutter/flutter#189152)
2026-07-09 katelovett@google.com Fix data for design packages (flutter/flutter#189140)
2026-07-09 engine-flutter-autoroll@skia.org Roll Skia from 7b42d1251d54 to ab3a7b98c94d (2 revisions) (flutter/flutter#189181)
2026-07-09 engine-flutter-autoroll@skia.org Roll Skia from 05d9d214e0b7 to 7b42d1251d54 (2 revisions) (flutter/flutter#189175)
2026-07-09 engine-flutter-autoroll@skia.org Roll Skia from 542c8bdd7f4f to 05d9d214e0b7 (4 revisions) (flutter/flutter#189169)
2026-07-09 97480502+b-luk@users.noreply.github.com UberSDF rect handling for thin (line-like) rectangles (flutter/flutter#188821)
2026-07-09 engine-flutter-autoroll@skia.org Roll Skia from dd572c07f63c to 542c8bdd7f4f (4 revisions) (flutter/flutter#189160)
2026-07-09 markzipan@google.com [flutter_tools] Fix hot restart for WASM web builds (flutter/flutter#187898)
2026-07-08 robert.ancell@canonical.com Split FlViewRenderer into OpenGL and software backends (flutter/flutter#188824)
2026-07-08 awolff@google.com Promote android_hardware_smoke_tests out of bringup in CI (flutter/flutter#189081)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 8df24be66531 to dd572c07f63c (4 revisions) (flutter/flutter#189150)
2026-07-08 matt.kosarek@canonical.com Expose LinuxWindowRegistrar on _window_linux.dart in order to better support out of tree LinuxWindowingOwners (flutter/flutter#188917)
2026-07-08 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#189149)
2026-07-08 codefu@google.com fix(ci): harden some workflows (flutter/flutter#189087)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 51a62da33da0 to 8df24be66531 (1 revision) (flutter/flutter#189139)
2026-07-08 iinozemtsev@google.com Roll Dart SDK to Dart 3.13 beta3 (flutter/flutter#189122)
2026-07-08 digvijaysinghiam@gmail.com [flutter_tools] Don't crash on non-UTF-8 plugin pubspec.yaml (flutter/flutter#188976)
2026-07-08 bkonyi@google.com [flutter_tools] Watch transitive #include headers for FragmentProgram hot reload (flutter/flutter#187945)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 040d9f55de00 to 51a62da33da0 (1 revision) (flutter/flutter#189135)
2026-07-08 engine-flutter-autoroll@skia.org Roll Packages from 92525f5 to 52d84d6 (7 revisions) (flutter/flutter#189134)
2026-07-08 bkonyi@google.com [flutter_tools] Forcefully kill hung subprocesses 5 seconds after timeout (flutter/flutter#187178)
2026-07-08 malo.allee@gmail.com Expose the app's build name and number as compile-time constants (flutter/flutter#187935)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 1ff92f879815 to 040d9f55de00 (1 revision) (flutter/flutter#189131)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 6137414bef5c to 1ff92f879815 (6 revisions) (flutter/flutter#189126)
2026-07-08 brackenavaron@gmail.com [test cross imports] More test/rendering + flutter_test/test fixes (flutter/flutter#188954)
2026-07-08 112751483+shivanshu877@users.noreply.github.com engine: explain why each candidate build was skipped in Flutter web loader (flutter/flutter#186254)
2026-07-08 chris@bracken.jp vscode: add missing unicode.h (flutter/flutter#189102)
2026-07-08 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 7RjQJBW3m-3Jl-7jr... to QcRFUtvCw2EobfJ8s... (flutter/flutter#189104)
2026-07-08 engine-flutter-autoroll@skia.org Roll Skia from 075fbe4778d9 to 6137414bef5c (10 revisions) (flutter/flutter#189106)
2026-07-08 112751483+shivanshu877@users.noreply.github.com engine: warn on WASM load failure when not crossOriginIsolated (flutter/flutter#186252)
2026-07-08 engine-flutter-autoroll@skia.org Roll Dart SDK from c9bccc09e733 to db2155f56bf3 (2 revisions) (flutter/flutter#189105)
2026-07-08 bkonyi@google.com [flutter_tools] Prevent interactive device selection in machine mode (flutter/flutter#188267)
2026-07-08 bkonyi@google.com [flutter_tools] Fix wireless ADB device discovery when serial contains spaces (flutter/flutter#187943)
2026-07-07 zhongliu88889@gmail.com [web] Fix grouped autofill on iOS Chrome (flutter/flutter#187459)
2026-07-07 rmolivares@renzo-olivares.dev Fix TextSelectionOverlay crash when layout is degenerate (flutter/flutter#188672)
2026-07-07 87962825+kyungilcho@users.noreply.github.com [flutter_tools] Provision Android NDK in the main Gradle invocation (flutter/flutter#186337)
2026-07-07 awolff@google.com Android_hardware_smoke_test: Migrate to AGP 9 (flutter/flutter#189082)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD 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

Development

Successfully merging this pull request may close these issues.

2 participants