-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team
Description
Steps to reproduce
- Setup a new app
- Load a custom fragment shader
- Store the shader as a state variable in a widget
- Use
ImageFilter.shader()in your widget, e.g.ImageFiltered - Update the shader, e.g. using
shader.setFloat - Run the app on macOS
Expected results
The shader will be updated and has access to the updated value. Accordingly, the ui updates. Since the shader I use is (nearly) the example from ImageFilter.shader docs, I assumed this would be possible without any problems.
Actual results
There is no ui update happening
Code sample
Code sample
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:playground_presentation/main.dart';
class BasicPage extends StatelessWidget {
const BasicPage({super.key});
@override
Widget build(BuildContext context) {
return _Content();
}
}
class _Content extends StatefulWidget {
const _Content({super.key});
@override
State<_Content> createState() => __ContentState();
}
class __ContentState extends State<_Content>
with SingleTickerProviderStateMixin {
late FragmentShader shader;
late final Ticker ticker;
@override
void initState() {
super.initState();
shader =
ShaderData.of(context).shaderCollection.basicShader.fragmentShader();
ticker = createTicker((elapsed) {
shader.setFloat(2, (elapsed.inMilliseconds % 1000) / 1000);
setState(() {});
})
..start();
;
}
@override
Widget build(BuildContext context) {
return ImageFiltered(
imageFilter: ImageFilter.shader(shader),
child: Scaffold(
appBar: AppBar(
title: Text("Basic Page"),
),
body: Center(
child: ElevatedButton(
onPressed: () {},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Hello, World!',
style: TextStyle(
fontSize: 24,
),
),
),
),
),
),
);
}
}
shader:
#include <flutter/runtime_effect.glsl>
uniform vec2 u_size;
uniform float u_time;
uniform sampler2D u_texture_input;
out vec4 frag_color;
void main() {
frag_color = texture(u_texture_input, FlutterFragCoord().xy / u_size) * vec4(1, 0.6, 0.8, 1.0) * u_time;
}Screenshots or Video
Screenshots / Video demonstration
Wanted behavior:
Bildschirmaufnahme.2025-02-14.um.13.15.12.mov
This example is done by setting the key of the ImageFiltered to UniqueKey(), which I assume is not the way this should be done.
Actual Behavior:
Bildschirmaufnahme.2025-02-14.um.13.15.26.mov
Logs
Logs
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.1.1 24B91 darwin-arm64, locale de-DE) [413ms]
• Flutter version 3.29.0 on channel stable at /Users/florianvoegtle/fvm/versions/3.29.0
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 35c388afb5 (4 days ago), 2025-02-10 12:48:41 -0800
• Engine revision f73bfc4522
• Dart version 3.7.0
• DevTools version 2.42.2
• Pub download mirror https://pub.dev
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1.207ms]
• Android SDK at /Users/florianvoegtle/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• Java binary at: /Users/florianvoegtle/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639/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 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [964ms]
• Xcode at /Applications/Xcode-16.1.0.app/Contents/Developer
• Build 16B40
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [10ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2) [9ms]
• Android Studio at /Users/florianvoegtle/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/222.4459.24.2221.10121639/Android
Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.97.2) [8ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.104.0
[✓] Connected device (4 available) [6,3s]
• iPhone von Florian (2) (wireless) (mobile) • 00008130-00050554342B803A • ios • iOS 18.3.1 22D72
• macOS (desktop) • macos • darwin-arm64 • macOS 15.1.1 24B91 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1.1 24B91 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.98
[✓] Network resources [522ms]
• All expected network resources are available.
• No issues found!itspectre, aloisdeniel and ahmed-alvis
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team