-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
e: device-specificOnly manifests on certain devicesOnly manifests on certain devicese: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight
Description
Steps to reproduce
- Create a sample project using
flutter create. - Run the
flutter pub add flutter_shaderscommand. - Add a shader file called shader.frag into a folder called shaders in the root of your project and paste in the shader code from the code snippet below.
- Add
flutter:
shaders:
- shaders/shader.frag
to the pubspec.yaml
5. Paste in the dart code into main.dart from the sample below.
6. Run on multiple platforms, I see a difference between Linux and Android.
Also, the app sometimes launches just a black screen on the phone and nothing more happens, the progress indicator notification pop-up in VS Code is stuck at 'Installing', might be a different issue though.
Expected results
The VRAM memory doesn't overflow.
Actual results
On my android device (POCO X3 Pro) after running for a few seconds I get flooded by error messages, which can be found in the logs section below.
Runs fine on Linux (Ubuntu), no memory overflow there.
Code sample
Code sample
Fragment shader code:
#version 460 core
#include <flutter/runtime_effect.glsl>
uniform vec2 uSize;
uniform float uTime;
uniform sampler2D uWidget;
out vec4 fragColor;
void main()
{
vec2 pos = FlutterFragCoord().xy / uSize;
fragColor = mix(vec4(sin(pos.x * uTime * 0.5), pos.y, 0.78, 1.0), texture(uWidget, pos), 0.5);
}
Dart code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_shaders/flutter_shaders.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple)),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
Widget build(BuildContext context) {
return ShaderBuilder(
(context, shader, _) => Scaffold(
body: Center(child: Sampler(shader: shader)),
),
assetKey: 'shaders/shader.frag',
);
}
}
class Sampler extends StatefulWidget {
const Sampler({super.key, required this.shader});
final FragmentShader shader;
@override
State<Sampler> createState() => _SamplerState();
}
class _SamplerState extends State<Sampler> with SingleTickerProviderStateMixin {
late final Ticker _timer;
double _time = 0.0;
@override
void initState() {
super.initState();
_timer = createTicker((elapsed) {
setState(() {
_time = elapsed.inMilliseconds.toDouble();
});
})..start();
}
@override
Widget build(BuildContext context) {
return AnimatedSampler(
(image, size, canvas) {
widget.shader
..setFloat(0, size.width)
..setFloat(1, size.height)
..setFloat(2, _time)
..setImageSampler(0, image);
canvas.drawRect(Offset.zero & size, Paint()..shader = widget.shader);
},
child: Text('0', style: Theme.of(context).textTheme.displayLarge!.copyWith(fontSize: 520.0)),
key: ValueKey('value'),
);
}
@override
void dispose() {
_timer.dispose();
super.dispose();
}
}Screenshots or Video
No response
Logs
Logs
E/flutter (28651): [ERROR:flutter/impeller/renderer/backend/vulkan/allocator_vk.cc(361)] Break on 'ImpellerValidationBreak' to inspect point of failure: Unable to allocate Vulkan Image: ErrorOutOfDeviceMemory Type: Texture2DMultisample Mode: DeviceTransient Usage: { RenderTarget } [VK]Flags: {} [VK]Format: R8G8B8A8Unorm [VK]Usage: { ColorAttachment | InputAttachment } [VK]Mem. Flags: { DeviceLocal }
E/flutter (28651): [ERROR:flutter/impeller/renderer/render_target.cc(411)] Break on 'ImpellerValidationBreak' to inspect point of failure: Could not create multisample color texture.
E/flutter (28651): [ERROR:flutter/impeller/renderer/render_target.cc(26)] Break on 'ImpellerValidationBreak' to inspect point of failure: Render target does not have color attachment at index 0.
W/Adreno-GSL(28651): <gsl_ldd_control:553>: ioctl fd 112 code 0xc0300945 (IOCTL_KGSL_GPUOBJ_ALLOC) failed: errno 12 Out of memory
E/Adreno-GSL(28651): <gsl_memory_alloc_pure:2604>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.Flutter Doctor output
Doctor output
anims flutter doctor -v
[✓] Flutter (Channel stable, 3.35.5, on Ubuntu 24.04.3 LTS 6.14.0-34-generic, locale en_US.UTF-8) [40ms]
• Flutter version 3.35.5 on channel stable at /home/daniel/Development/vendor/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ac4e799d23 (7 weeks ago), 2025-09-26 12:05:09 -0700
• Engine revision d3d45dcf25
• Dart version 3.9.2
• DevTools version 2.48.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios,
cli-animations, enable-lldb-debugging
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.5s]
• Android SDK at /home/daniel/Development/vendor/android/android-sdk
• Emulator version 35.3.12.0 (build_id 12990079) (CL:N/A)
• Platform android-36, build-tools 35.0.0
• ANDROID_HOME = /home/daniel/Development/vendor/android/android-sdk
• ANDROID_SDK_ROOT = /home/daniel/Development/vendor/android/android-sdk
• Java binary at: /home/daniel/Development/vendor/java/jdk-17.0.14+7/bin/java
This JDK is specified by the JAVA_HOME environment variable.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Temurin-17.0.14+7 (build 17.0.14+7)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) [7ms]
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop [242ms]
• Ubuntu clang version 18.1.3 (1ubuntu1)
• cmake version 3.28.1
• ninja version 1.11.1
• pkg-config version 1.8.1
• OpenGL core renderer: AMD Radeon RX 7700 XT (radeonsi, navi32, LLVM 20.1.8, DRM 3.61, 6.14.0-34-generic) (X11)
• OpenGL core version: 4.6 (Core Profile) Mesa 25.2.5 - kisak-mesa PPA (X11)
• OpenGL core shading language version: 4.60 (X11)
• OpenGL ES renderer: AMD Radeon RX 7700 XT (radeonsi, navi32, LLVM 20.1.8, DRM 3.61, 6.14.0-34-generic) (X11)
• OpenGL ES version: OpenGL ES 3.2 Mesa 25.2.5 - kisak-mesa PPA (X11)
• OpenGL ES shading language version: OpenGL ES GLSL ES 3.20 (X11)
• GL_EXT_framebuffer_blit: yes (X11)
• GL_EXT_texture_format_BGRA8888: yes (X11)
[!] Android Studio (not installed) [5ms]
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
[✓] VS Code (version 1.105.1) [5ms]
• VS Code at /usr/share/code
• Flutter extension version 3.122.0
[✓] Connected device (2 available) [155ms]
• M2102J20SG (mobile) • 192.0.0.2:5555 • android-arm64 • Android 13 (API 33)
• Linux (desktop) • linux • linux-x64 • Ubuntu 24.04.3 LTS 6.14.0-34-generic
[✓] Network resources [750ms]
• All expected network resources are available.Metadata
Metadata
Assignees
Labels
e: device-specificOnly manifests on certain devicesOnly manifests on certain devicese: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamOwned by Engine teamwaiting for PR to land (fixed)A fix is in flightA fix is in flight