Repository navigation
Closed
Labels
e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.team-fluttergpuOwned by Flutter GPU team
Description
Steps to reproduce
- On Linux x64, build
impeller_unittestsfrom master d03768e with the test from the code sample below added toimpeller/renderer/backend/gles/test/pipeline_library_gles_unittests.cc(also once with--tsan). - Run it under Xvfb with Mesa, as in CI:
xvfb-run impeller_unittests --gtest_filter='*CanLookUpPipelinesWhileCreatingPipelines/OpenGLES'.
Expected results
HasPipeline and GetPipeline can run on one thread while another thread creates pipelines, as Flutter GPU does.
Actual results
PipelineLibraryGLES locks programs_ but not pipelines_, and GetPipeline inserts into pipelines_ on the calling thread (only program linking runs on the reactor). Flutter GPU calls HasPipeline and GetPipeline on the UI thread (RenderPass::GetOrCreatePipeline) while Impeller inserts variants on the raster thread.
- The test fails in 32 of 40 runs: the reader thread misses a pipeline that already exists.
- Under TSan, all 10 runs report the race between
GetPipeline(insert) andHasPipeline(lookup). - With a mutex on
pipelines_, it passes 40/40 and TSan reports nopipelines_race.
This is confirmed only with this engine test on Linux (Mesa), not in an app. It is a sibling of #193721 (Metal pipelines) and #193737 (samplers).
Code sample
Test
Also needs <atomic>, <string>, <thread> and flutter/fml/synchronization/count_down_latch.h.
TEST_P(PipelineLibraryGLESTest, CanLookUpPipelinesWhileCreatingPipelines) {
using VS = SpecConstantVertexShader;
using FS = SpecConstantFragmentShader;
std::shared_ptr<Context> context = GetContext();
ASSERT_TRUE(context);
std::optional<PipelineDescriptor> desc =
PipelineBuilder<VS, FS>::MakeDefaultPipelineDescriptor(*context);
ASSERT_TRUE(desc.has_value());
std::shared_ptr<PipelineLibrary> library = context->GetPipelineLibrary();
ASSERT_TRUE(library->GetPipeline(desc).Get());
std::atomic_bool done = false;
std::atomic_int misses = 0;
fml::CountDownLatch reading(1);
std::thread reader([&] {
reading.CountDown();
while (!done) {
if (!library->HasPipeline(desc.value()) ||
!library->GetPipeline(desc.value()).IsValid()) {
misses++;
}
}
});
reading.Wait();
for (int i = 0; i < 128; i++) {
PipelineDescriptor variant = desc.value();
variant.SetLabel("Variant " + std::to_string(i));
std::shared_ptr<Pipeline<PipelineDescriptor>> pipeline =
library->GetPipeline(variant).Get();
EXPECT_TRUE(pipeline && pipeline->IsValid());
}
done = true;
reader.join();
EXPECT_EQ(misses, 0);
}Screenshots or Video
N/A
Logs
TSan, master d03768e (Linux x64, Mesa, Xvfb)
WARNING: ThreadSanitizer: data race
Write of size 8 by main thread:
#1 std::unordered_map<PipelineDescriptor, PipelineFuture<PipelineDescriptor>>::operator[]()
#2 impeller::PipelineLibraryGLES::GetPipeline(PipelineDescriptor, bool, bool) pipeline_library_gles.cc:301
#3 PipelineLibraryGLESTest_CanLookUpPipelinesWhileCreatingPipelines_Test::TestBody()
Previous read of size 8 by thread T67:
#1 std::unordered_map<PipelineDescriptor, PipelineFuture<PipelineDescriptor>>::find()
#2 impeller::PipelineLibraryGLES::HasPipeline(PipelineDescriptor const&) pipeline_library_gles.cc:347
#3 PipelineLibraryGLESTest_CanLookUpPipelinesWhileCreatingPipelines_Test::TestBody()::$_0::operator()()pipeline_library_gles_unittests.cc: Failure
Expected equality of these values:
misses
Which is: 2
[ FAILED ] Play/PipelineLibraryGLESTest.CanLookUpPipelinesWhileCreatingPipelines/OpenGLESFlutter Doctor output
flutter doctor -v (the machine that found the related races; the GLES result comes from the engine build above)
[✓] Flutter (Channel stable, 3.47.1, on macOS 26.7 25G229 darwin-arm64, locale en-CA) [1,710ms]
• Flutter version 3.47.1 on channel stable at /Users/<user>/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6655482ec0 (6 weeks ago), 2026-08-19 10:07:23 -0700
• Engine revision 5d53178869
• Dart version 3.13.1
• DevTools version 2.60.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [4.4s]
• Android SDK at /Users/<user>/Library/Android/sdk
• Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
• Platform android-36.1, build-tools 36.1.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.10+-117844308-b1163.108)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 27.0) [4.5s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 27A266a
! iOS 27.0 Simulator not installed; this may be necessary for iOS and macOS development.
To download and install the platform, open Xcode, select Xcode > Settings > Components,
and click the GET button for the required platform.
For more information, please visit:
https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [7ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (3 available) [7.3s]
• iPhone 17 Pro (mobile) • <simulator-udid> • ios • com.apple.CoreSimulator.SimRuntime.iOS-26-4 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 26.7 25G229 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 154.0.8037.95
[✓] Network resources [1,093ms]
• All expected network resources are available.
! Doctor found issues in 1 category.Metadata
Metadata
Assignees
Labels
e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.team-fluttergpuOwned by Flutter GPU team
Activity
suryaKommana2662 commentedon Oct 5, 2026
@leehack Thanks for the report. Noticed that this was tested on Flutter 3.47.1. Could you please confirm whether the issue is still reproducible on the latest stable Flutter release, 3.47.6? Once confirmed, we can route the issue to the appropriate team for further investigation.
leehack commentedon Oct 5, 2026
The issue was initially reproduced on 3.47.1, and I have the SDK installed on my machine. That's why the doctor is showing the version, but it's tested and reproduced on the main branch.
You can also see the fix PR: #193746
gaaclarke commentedon Oct 12, 2026
This code is being reworked in #194022 and may address the issue.
[Flutter GPU] Record on the UI thread, encode and submit on the raste…