Skip to content

TextShadowCache leaks memory on OpenGL ES. #178276

Closed

Description

@feag2

Steps to reproduce

You can reproduce the problem by simply running the code above, but it requires certain devices, such as the Galaxy A51 I found.

Expected results

The code above causes a continuous increase in memory usage on some Android phones. The model I've currently observed is a Galaxy A51 running Android 10, using the Impeller engine. The core issue is that the blurRadius property in the shadow and the loading of the GIF image, when done together, cause a bug that leads to continuous memory usage growth. These two conditions are necessary, but not every phone experiences this problem. I haven't found the same issue on iOS. I suspect that the blurRadius property is not supported on some models, even though the rendering is the same as for the GIF.

Actual results

Memory continues to grow

Code sample

Column(
      children: [
        SizedBox(height: 100,),
        Text(
          textAlign: TextAlign.center,
          'asjdhjasdh',
          style: TextStyle(
            color: Colors.white,
            fontSize: 25.fitWithScreenW,
            shadows: [
              Shadow(
                color: Color(0xff111111),
                offset: const Offset(0, 1), // 阴影的偏移量,(dx, dy)
                blurRadius: 2.0, // 模糊半径
              ),
            ],
          ),
        ),
        Image.network(
            'https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExbzhrbXg4dDRxdjEwNHptNHRncjJ4b280amh1bnlpOGd4OThyaXFzYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/JWnXY237vWeX3zx64V/giphy.gif',
            width: 72,
            height: 72),

      ],
    )

Screenshots or Video

Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

[!] Flutter (Channel [user-branch], 3.32.8, on macOS 14.5 23F79 darwin-arm64,
locale zh-Hans-CN)
! Flutter version 3.32.8 on channel [user-branch] at
/Users/liwei/flutter/flutter332
Currently on an unknown channel. Run flutter channel to switch to an
official channel.
If that doesn't fix the issue, reinstall Flutter by following instructions
at https://flutter.dev/setup.
! Upstream repository unknown source is not a standard remote.
Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss
this error.
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor
--android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.2)
[✓] VS Code (version 1.105.1)
[✓] Connected device (3 available)
[✓] Network resources

Activity

  1. tirth-patel-nc commented on Nov 11, 2025

    @tirth-patel-nc
    Member

    @feag2 Thanks for the report. Can you please upgrade to latest stable (3.35.7) / latest master and re-run your scenario to check if the reported behavior still persist on it or not ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 11, 2025
  3. feag2 commented on Nov 12, 2025

    @feag2
    Author

    @feag2 Thanks for the report. Can you please upgrade to latest stable (3.35.7) / latest master and re-run your scenario to check if the reported behavior still persist on it or not ?

    Image I use latest stable (3.35.7) ,The same problem persists; currently, only commenting out the blurRadius attribute can resolve it.
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 12, 2025
  5. tirth-patel-nc commented on Nov 13, 2025

    @tirth-patel-nc
    Member

    @feag2 I’m not observing any performance spikes on Pixel 6a using the latest stable (3.38.0) or master (3.39.0-1.0.pre-93) builds. Please share verbose logs from flutter run -v along with performance data as outlined here: https://docs.flutter.dev/tools/devtools/performance#import-and-export

    Image Image
  6. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 13, 2025
  7. liweiGe commented on Nov 13, 2025

    @liweiGe

    main-1_2025-11-13_16_26_53.097.csv

    Image

    long_text_841433b2-f89b-4cd5-92a5-86b7d3a64b8a.txt

    This issue isn't reproducible on every model; currently, it's only occurring on the Galaxy A51 (android 10) and oppo A54(Android 11)

    I test in flutter sdk 3.38.0 stable is also has this problem

  8. liweiGe commented on Nov 13, 2025

    @liweiGe

    memory.zip

    Image

    This is the CVS and data file. @tirth-patel-nc

  9. jason-simmons commented on Nov 22, 2025

    @jason-simmons
    Member

    Reproduced this when running with the Impeller GLES back end. The Vulkan back end appears to be unaffected.

    Each frame in this app renders a text shadow, which makes Impeller's TextShadowCache create a snapshot of the text contents. In the GLES back end something related to the snapshot texture/framebuffer appears to be leaking.

    (Next week is a holiday - will continue looking at this afterward)

  10. virskor commented on Dec 1, 2025

    @virskor

    using text shadow on infinite list could be slow. jittery

  11. github-actions commented on Dec 4, 2025

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  12. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Dec 4, 2025
  13. 6 remaining items

  14. added
    perf: memoryPerformance issues related to memory
    e: samsungIssues only reproducible on Samsung devices
    and removed
    in triagePresently being triaged by the triage team
    on Dec 5, 2025
  15. added
    P1High-priority issues at the top of the work list
    on Dec 8, 2025
  16. changed the title [-]impeller memory bug[/-] [+]TextShadowCache leaks memory on OpenGL ES.[/+] on Dec 8, 2025
  17. jason-simmons commented on Dec 12, 2025

    @jason-simmons
    Member

    This is happening because Impeller may delete OpenGL framebuffer objects on a background thread that can not correctly perform the deletion.

    OpenGL specifies that container objects (such as framebuffers) that hold references to other objects can not be shared across contexts. See https://wikis.khronos.org/opengl/OpenGL_Object#Object_Sharing

    The example app contains shadowed text along with an animated image. Each time the animated image advances, Impeller will render a scene containing the new image frame and the text.

    On the raster thread, the text's shadow causes the TextShadowCache to create a snapshot of the text content, and on GLES that involves creation of a framebuffer. Later, the framebuffer is released and its handle is collected by the ReactorGLES for future deletion.

    But at the same time, the decoding of the animated image is running frequent operations on the IO thread. These operations may trigger a ReactorGLES::ConsolidateHandles() call on the IO thread that executes deletion of any pending GLES objects.

    The raster thread's EGL context is in a share group with the IO thread's context, so most GLES objects can be safely deleted from either thread. But framebuffers are not shareable, so calling glDeleteFramebuffers on the IO thread does not have the intended effect.

    This can be fixed by ensuring that ReactorGLES deletes container objects using the thread and context that created the object.

  18. github-actions commented on Dec 30, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)e: device-specificOnly manifests on certain devicese: impellerImpeller rendering backend issues and features requestse: samsungIssues only reproducible on Samsung devicesengineflutter/engine related. See also e: labels.perf: memoryPerformance issues related to memoryr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions