Skip to content

[Linux] Retain software renderer frame state until finalization - #196546

Draft
saitatter wants to merge 1 commit into
flutter:masterfrom
saitatter:fix/linux-software-renderer-lifetime
Draft

saitatter wants to merge 1 commit into
flutter:masterfrom
saitatter:fix/linux-software-renderer-lifetime

Conversation

@saitatter

@saitatter saitatter commented Nov 13, 2026 •

Copy link
Copy Markdown

A realized software renderer can still present a frame after GTK destroys its widget while a strong reference keeps the instance alive. dispose() currently clears task_runner; present_layers() then reaches fl_task_runner_stop_wait(nullptr) and crashes in g_cond_signal().

Keep the task runner and frame mutex until finalize(), alongside the existing compositor and surface lifetime. Add a realized-widget regression; the existing unrealized-widget test returns before reaching this path.

Fixes #196545.

Related: #193533 handles OpenGL/Subsurface lifetime. This change is limited to the software renderer.

Validation

  • The new regression produces SIGSEGV on unmodified master 215858ff8a1e51fb5481c7c7cc4c6d4be54b8ae0; the symbolized stack shows fl_task_runner_stop_wait(self=0x0).
  • With the fix: 100 consecutive regression iterations and all 862 Linux engine unit tests pass under D-Bus/Xvfb on Ubuntu 24.04 / GTK 3.24.41.
  • The engine's bundled clang-format and pre-push formatting checks pass.
ninja -C engine/src/out/host_debug_unopt flutter_linux_unittests
dbus-run-session -- xvfb-run -a engine/src/out/host_debug_unopt/flutter_linux_unittests
dbus-run-session -- xvfb-run -a engine/src/out/host_debug_unopt/flutter_linux_unittests \
  --gtest_filter=FlViewRendererSoftwareTest.PresentLayersAfterRealizedDestroy \
  --gtest_repeat=100 --gtest_break_on_failure

Prepared with Codex assistance. Kept as a draft for contributor review under the AI contribution guidelines.

Pre-launch Checklist

A realized renderer may still receive an in-flight frame after forced GTK disposal while a strong reference is held. Keep the task runner and frame mutex alive with the compositor until finalization.

Fixes flutter#196545. Validation: failing original regression reproduced under GDB; fixed regression passed 100 repetitions; all 862 Linux engine unit tests passed.
@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
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

Development

Successfully merging this pull request may close these issues.

[Linux] Realized software renderer loses its task runner during GTK disposal

1 participant