Skip to content

[Impeller] Fix fail to render pixel buffer texture on Linux#181656

Merged
gaaclarke merged 7 commits intoflutter:masterfrom
xiaowei-guan:linux_texture
Feb 24, 2026
Merged

[Impeller] Fix fail to render pixel buffer texture on Linux#181656
gaaclarke merged 7 commits intoflutter:masterfrom
xiaowei-guan:linux_texture

Conversation

@xiaowei-guan
Copy link
Contributor

@xiaowei-guan xiaowei-guan commented Jan 29, 2026

Fix #181483

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

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

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.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions bot added the engine flutter/engine related. See also e: labels. label Jan 29, 2026
Copy link
Contributor

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

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 fixes an issue with rendering external OpenGL textures with Impeller on Linux. The changes include explicitly setting the texture format, using the correct texture name (ID) instead of the target when creating the Impeller texture handle, and setting the texture coordinate system to kUploadFromHost to ensure correct orientation.

I've suggested an improvement to avoid hardcoding the pixel format and instead derive it from the texture->format provided by the embedder, which would make the implementation more robust.

almassolarenrgi

This comment was marked as spam.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

@xiaowei-guan this PR doesn't have a test, unfortunately I'm not that familiar with this code so I can't give you a pointer on the best way to test it and I'm not readily seeing unit testing set up here. I cannot approve it without some sort of test though.

@xiaowei-guan
Copy link
Contributor Author

@xiaowei-guan this PR doesn't have a test, unfortunately I'm not that familiar with this code so I can't give you a pointer on the best way to test it and I'm not readily seeing unit testing set up here. I cannot approve it without some sort of test though.

OK, I will add unit test later.

@loic-sharma
Copy link
Member

For a test, these might be useful resources for prior art you can copy:

  1. This is the C++ code that launches the engine to render some content using OpenGL + Impeller:
    TEST_F(EmbedderTest, CanRenderWithImpellerOpenGL) {
    auto& context = GetEmbedderContext<EmbedderTestContextGL>();
    EmbedderConfigBuilder builder(context);
    bool present_called = false;
    context.SetGLPresentCallback(
    [&present_called](FlutterPresentInfo present_info) {
    present_called = true;
    });
    builder.AddCommandLineArgument("--enable-impeller");
    builder.SetDartEntrypoint("render_impeller_test");
    builder.SetSurface(DlISize(800, 600));
    builder.SetCompositor();
    builder.SetRenderTargetType(
    EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
    auto rendered_scene = context.GetNextSceneImage();
    auto engine = builder.LaunchEngine();
    ASSERT_TRUE(engine.is_valid());
    // Bind to an arbitrary FBO in order to verify that Impeller binds to the
    // provided FBO during rendering.
    typedef void (*glGenFramebuffersProc)(GLsizei n, GLuint* ids);
    typedef void (*glBindFramebufferProc)(GLenum target, GLuint framebuffer);
    auto glGenFramebuffers = reinterpret_cast<glGenFramebuffersProc>(
    context.GLGetProcAddress("glGenFramebuffers"));
    auto glBindFramebuffer = reinterpret_cast<glBindFramebufferProc>(
    context.GLGetProcAddress("glBindFramebuffer"));
    const flutter::Shell& shell = ToEmbedderEngine(engine.get())->GetShell();
    fml::AutoResetWaitableEvent raster_event;
    shell.GetTaskRunners().GetRasterTaskRunner()->PostTask([&] {
    GLuint fbo;
    glGenFramebuffers(1, &fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    raster_event.Signal();
    });
    raster_event.Wait();
    // Send a window metrics events so frames may be scheduled.
    FlutterWindowMetricsEvent event = {};
    event.struct_size = sizeof(event);
    event.width = 800;
    event.height = 600;
    event.pixel_ratio = 1.0;
    ASSERT_EQ(FlutterEngineSendWindowMetricsEvent(engine.get(), &event),
    kSuccess);
    ASSERT_TRUE(ImageMatchesFixture(
    FixtureNameForBackend(EmbedderTestContextType::kOpenGLContext,
    "impeller_test.png"),
    rendered_scene));
    // The scene will be rendered by the compositor, and the surface present
    // callback should not be invoked.
    ASSERT_FALSE(present_called);
    }
  2. This is the Dart code that renders some content:
    @pragma('vm:entry-point')
    // ignore: non_constant_identifier_names
    void render_impeller_test() {
    PlatformDispatcher.instance.onBeginFrame = (Duration duration) {
    final builder = SceneBuilder();
    builder.pushOffset(0.0, 0.0);
    final paint = Paint();
    paint.color = const Color.fromARGB(255, 0, 0, 255);
    final baseRecorder = PictureRecorder();
    final canvas = Canvas(baseRecorder);
    canvas.drawPaint(Paint()..color = const Color.fromARGB(255, 255, 0, 0));
    canvas.drawRect(const Rect.fromLTRB(20.0, 20.0, 200.0, 150.0), paint);
    builder.addPicture(Offset.zero, baseRecorder.endRecording());
    builder.pop();
    PlatformDispatcher.instance.views.first.render(builder.build());
    };
    PlatformDispatcher.instance.scheduleFrame();
  3. This is the snapshot of the expected test output: https://github.com/flutter/flutter/blob/9b9f9975c76a1474b96426d22cd34cc589ad6f53/engine/src/flutter/shell/platform/embedder/fixtures/impeller_test.png

@xiaowei-guan
Copy link
Contributor Author

xiaowei-guan commented Feb 9, 2026

@xiaowei-guan this PR doesn't have a test, unfortunately I'm not that familiar with this code so I can't give you a pointer on the best way to test it and I'm not readily seeing unit testing set up here. I cannot approve it without some sort of test though.

@gaaclarke I have added a unit test for rendering a impeller texture.

@gaaclarke gaaclarke self-requested a review February 9, 2026 17:39
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks. Can you make one change though please, can you make the texture sensitive to orientation so we can assert your change to the images coordinate system?

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm! thanks

Copy link
Member

@jason-simmons jason-simmons left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 11, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 11, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 11, 2026

autosubmit label was removed for flutter/flutter/181656, because - The status or check suite Windows tool_integration_tests_7_9 has failed. Please fix the issues identified (or deflake) before re-applying this label.

@xiaowei-guan
Copy link
Contributor Author

Rebased

@fluttergithubbot
Copy link
Contributor

An existing Git SHA, 8004628ca0401a70bec720d16800ae8b71f43eae, was detected, and no actions were taken.

To re-trigger presubmits after closing or re-opeing a PR, or pushing a HEAD commit (i.e. with --force) that already was pushed before, push a blank commit (git commit --allow-empty -m "Trigger Build") or rebase to continue.

@gaaclarke
Copy link
Member

Notes from google testing: There is a merge conflict in the PR that cannot be rolled cleanly, please rebase the PR.

We just rebased, but I'll try again.

@gaaclarke
Copy link
Member

jinx

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 12, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 12, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 12, 2026

autosubmit label was removed for flutter/flutter/181656, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 12, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 12, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Feb 12, 2026

autosubmit label was removed for flutter/flutter/181656, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@xiaowei-guan
Copy link
Contributor Author

Rebase again

@xiaowei-guan
Copy link
Contributor Author

I have rebased locally against upstream/master and forced pushed, but the g3 conflict persists. Could a maintainer help check if this is an internal sync issue?

1.Make the texture red on the top half and blue on the botton half.
2.Add a new image file.
Only support GL_RGBA8 format now.
@gaaclarke
Copy link
Member

It's reporting a merge conflict, I tried to hit the button to attempt again but no luck. There is zero feedback about where the merge conflict is happening. I'll try reaching out to someone that works on this tool.

@gaaclarke gaaclarke added this pull request to the merge queue Feb 24, 2026
Merged via the queue into flutter:master with commit 450478a Feb 24, 2026
183 checks passed
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 26, 2026
Roll Flutter from dad6f9d4107a to b31548feb941 (39 revisions)

flutter/flutter@dad6f9d...b31548f

2026-02-25 [email protected] [web] Fix failure on Firefox 148 (flutter/flutter#182855)
2026-02-25 [email protected] Roll Fuchsia Linux SDK from KfPgw04T0OEADLJA5... to XI0Ax7fbtYE4XKYAQ... (flutter/flutter#182887)
2026-02-25 [email protected] Use AnimationStyle curve and reverseCurve in ModalBottomSheet animation (flutter/flutter#181403)
2026-02-25 [email protected] Roll Dart SDK from fd3dce5b6a4e to 5c57e75f1102 (9 revisions) (flutter/flutter#182801)
2026-02-25 98614782+auto-submit[bot]@users.noreply.github.com Reverts "refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (#182697)" (flutter/flutter#182879)
2026-02-25 [email protected] Make sure that an AnimatedSlide doesn't crash in 0x0 environment (flutter/flutter#181535)
2026-02-24 [email protected] Reland Standardize on Test* widgets in *_tester.dart files (flutter/flutter#182632)
2026-02-24 [email protected] docs(Path): clarify that zero-length contours are excluded from computeMetrics (flutter/flutter#180165)
2026-02-24 [email protected] Fix typo in assert message (flutter/flutter#182843)
2026-02-24 [email protected] [win32] Fix overflow in TaskRunnerWindow. (flutter/flutter#182822)
2026-02-24 [email protected] feat: Add --no-uninstall flag to flutter test for integration tests (flutter/flutter#182714)
2026-02-24 [email protected] Rename noFrequencyBasedMinification to useFrequencyBasedMinification (flutter/flutter#182684)
2026-02-24 [email protected] [Impeller] Fix fail to render pixel buffer texture on Linux (flutter/flutter#181656)
2026-02-24 [email protected] Remove FlutterFramework app migration (flutter/flutter#182100)
2026-02-24 [email protected] Roll Packages from 12b43a1 to 062c8d4 (5 revisions) (flutter/flutter#182839)
2026-02-24 [email protected] [web] Run webparagraph tests in CI (flutter/flutter#182092)
2026-02-24 [email protected] Fix a race in EmbedderTest.CanSpecifyCustomUITaskRunner (flutter/flutter#182649)
2026-02-24 [email protected] flutter_tools: Use a super-parameter in several missed cases (flutter/flutter#182581)
2026-02-24 [email protected] Replace more references to `flutter/engine` with `flutter/flutter` (flutter/flutter#182654)
2026-02-24 [email protected] Carousel: Migration from Scrollable+Viewport to CustomScrollView (flutter/flutter#182475)
2026-02-24 [email protected] Refactor impellerc_main to better organize some of its logic (flutter/flutter#182783)
2026-02-24 [email protected] Remove unused `getPluginList ` (flutter/flutter#182660)
2026-02-24 [email protected] Refactor: Remove material from ticker provider test (flutter/flutter#181697)
2026-02-24 [email protected] Roll Skia from 26eebffe12bd to f44d7db68805 (3 revisions) (flutter/flutter#182821)
2026-02-24 [email protected] refactor: remove material in context_menu_controller_test, icon_test, list_wheel_scroll_view_test, media_query_test, platform_menu_bar_test (flutter/flutter#182697)
2026-02-24 [email protected] Roll Skia from 7dad66aae75a to 26eebffe12bd (5 revisions) (flutter/flutter#182810)
2026-02-24 [email protected] Update roadmap for 2026 (flutter/flutter#182798)
2026-02-24 [email protected] Marks Windows tool_tests_commands_1_2 to be unflaky (flutter/flutter#179670)
2026-02-23 [email protected] [web] scroll iOS iframe text input into view (flutter/flutter#179759)
2026-02-23 [email protected] Fix textscaler clamp assertion error (flutter/flutter#181716)
2026-02-23 [email protected] Roll Skia from 9a5a3c92c336 to 7dad66aae75a (4 revisions) (flutter/flutter#182779)
2026-02-23 [email protected] Move more getters from userMessages class to the appropriate places (flutter/flutter#182656)
2026-02-23 [email protected] Manual roll Dart SDK from f8fac50475b8 to fd3dce5b6a4e (6 revisions) (flutter/flutter#182768)
2026-02-23 [email protected] Copy Flutter framework to Add to App FlutterPluginRgistrant (flutter/flutter#182523)
2026-02-23 [email protected] Add progress indicator to artifact downloads (flutter/flutter#181808)
2026-02-23 [email protected] Clarify batch release mode requirements (flutter/flutter#182228)
2026-02-23 [email protected] [web] Remove --disable-gpu from flutter chrome tests (flutter/flutter#182618)
2026-02-23 [email protected] running-apps: update running-apps to use Duration.ago() (flutter/flutter#182172)
2026-02-23 [email protected] Refactor bin/ shell scripts for better performance and safety (flutter/flutter#182674)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

...
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
…181656)

Fix flutter#181483
<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

*Replace this paragraph with a description of what this PR is changing
or adding, and why. Consider including before/after screenshots.*

*List which issues are fixed by this PR. You must list at least one
issue. An issue is not required if the PR fixes something trivial like a
typo.*

*If you had to change anything in the [flutter/tests] repo, include a
link to the migration guide as per the [breaking change policy].*

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] Fail to render pixel buffer texture on Linux

6 participants