Repository navigation
TextShadowCache leaks memory on OpenGL ES. #178276
Description
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
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
tirth-patel-nc commentedon Nov 11, 2025
@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 ?
feag2 commentedon Nov 12, 2025
tirth-patel-nc commentedon Nov 13, 2025
@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
liweiGe commentedon Nov 13, 2025
main-1_2025-11-13_16_26_53.097.csv
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
liweiGe commentedon Nov 13, 2025
memory.zip
This is the CVS and data file. @tirth-patel-nc
jason-simmons commentedon Nov 22, 2025
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
TextShadowCachecreate 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)
virskor commentedon Dec 1, 2025
using text shadow on infinite list could be slow. jittery
github-actions commentedon Dec 4, 2025
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.
6 remaining items
[-]impeller memory bug[/-][+]TextShadowCache leaks memory on OpenGL ES.[/+]jason-simmons commentedon Dec 12, 2025
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
TextShadowCacheto 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 theReactorGLESfor 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
glDeleteFramebufferson the IO thread does not have the intended effect.This can be fixed by ensuring that
ReactorGLESdeletes container objects using the thread and context that created the object.[Impeller] Delete GLES framebuffer objects only on the thread where t…
[Impeller] Delete GLES framebuffer objects only on the thread where t…
[Impeller] Delete GLES framebuffer objects only on the thread where t…
github-actions commentedon Dec 30, 2025
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 -vand a minimal reproduction of the issue.[Impeller] Delete GLES framebuffer objects only on the thread where t…