Skip to content

Update intro_flutter_gpu for Flutter main #2332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions flutter_ci_script_shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ function ci_codelabs () {

# intro_flutter_gpu only runs with Impeller
if [ $CODELAB = 'intro_flutter_gpu' ]; then
# Skipping Windows: https://github.com/bdero/flutter_scene/issues/55
if [ $RUNNER_OS = 'macOS' ] || [ $RUNNER_OS = 'Linux' ]; then
# Skipping Windows and Linux: https://github.com/bdero/flutter_scene/issues/55
if [ $RUNNER_OS = 'macOS' ]; then
flutter config --enable-native-assets
flutter build `echo $RUNNER_OS | tr '[:upper:]' '[:lower:]'` --debug
flutter test --enable-impeller
flutter test --enable-flutter-gpu
else
echo "Skipping $CODELAB on $RUNNER_OS"
fi
Expand Down
39 changes: 35 additions & 4 deletions intro_flutter_gpu/codelab_rebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ steps:
testWidgets('smoke test', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MainApp());
}, skip: true);
}, skip: true); // https://github.com/flutter/flutter/issues/173650
}
- name: Patch macos/Runner/Info.plist
path: intro_flutter_gpu/macos/Runner/Info.plist
Expand All @@ -285,11 +285,42 @@ steps:
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
+ <!-- flutter_gpu requires Impeller -->
+ <key>FLTEnableImpeller</key>
+ <!-- Required for flutter_gpu -->
+ <key>FLTEnableFlutterGPU</key>
+ <true />
</dict>
</plist>
- name: Patch ios/Runner/Info.plist
path: intro_flutter_gpu/ios/Runner/Info.plist
patch-u: |
--- a/intro_flutter_gpu/step_12/ios/Runner/Info.plist
+++ b/intro_flutter_gpu/step_12/ios/Runner/Info.plist
@@ -45,5 +45,8 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
+ <!-- Required for flutter_gpu -->
+ <key>FLTEnableFlutterGPU</key>
+ <true />
</dict>
</plist>
- name: Patch android/app/src/main/AndroidManifest.xml
path: intro_flutter_gpu/android/app/src/main/AndroidManifest.xml
patch-u: |
--- a/intro_flutter_gpu/step_12/android/app/src/main/AndroidManifest.xml
+++ b/intro_flutter_gpu/step_12/android/app/src/main/AndroidManifest.xml
@@ -3,6 +3,11 @@
android:label="intro_flutter_gpu"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
+
+ <meta-data
+ android:name="io.flutter.embedding.android.EnableFlutterGPU"
+ android:value="true" />
+
<activity
android:name=".MainActivity"
android:exported="true"
- name: Copy step_01
copydir:
from: intro_flutter_gpu
Expand Down Expand Up @@ -2218,7 +2249,7 @@ steps:
+ await tester.pumpWidget(
+ MainApp(staticResourcesInitialized: Scene.initializeStaticResources()),
+ );
}, skip: true);
}, skip: true); // https://github.com/flutter/flutter/issues/173650
}
- name: Copy step_12
copydir:
Expand Down
2 changes: 1 addition & 1 deletion intro_flutter_gpu/step_01/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ migrate_working_dir/
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/

# Symbolication related
app.*.symbols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
android:label="intro_flutter_gpu"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<meta-data
android:name="io.flutter.embedding.android.EnableFlutterGPU"
android:value="true" />

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
5 changes: 4 additions & 1 deletion intro_flutter_gpu/step_01/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ allprojects {
}
}

val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
Expand Down
1 change: 0 additions & 1 deletion intro_flutter_gpu/step_01/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
17 changes: 9 additions & 8 deletions intro_flutter_gpu/step_01/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
pluginManagement {
val flutterSdkPath = run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

Expand All @@ -18,7 +19,7 @@ pluginManagement {

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.3" apply false
id("com.android.application") version "8.9.1" apply false
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -472,7 +472,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -523,7 +523,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
3 changes: 3 additions & 0 deletions intro_flutter_gpu/step_01/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<!-- Required for flutter_gpu -->
<key>FLTEnableFlutterGPU</key>
<true />
</dict>
</plist>
16 changes: 15 additions & 1 deletion intro_flutter_gpu/step_01/linux/runner/my_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ struct _MyApplication {

G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)

// Called when first Flutter frame received.
static void first_frame_cb(MyApplication* self, FlView *view)
{
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
}

// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
Expand Down Expand Up @@ -48,15 +54,23 @@ static void my_application_activate(GApplication* application) {
}

gtk_window_set_default_size(window, 1280, 720);
gtk_widget_show(GTK_WIDGET(window));

g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);

FlView* view = fl_view_new(project);
GdkRGBA background_color;
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
gdk_rgba_parse(&background_color, "#000000");
fl_view_set_background_color(view, &background_color);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));

// Show the window when Flutter renders.
// Requires the view to be realized so we can start rendering.
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
gtk_widget_realize(GTK_WIDGET(view));

fl_register_plugins(FL_PLUGIN_REGISTRY(view));

gtk_widget_grab_focus(GTK_WIDGET(view));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -543,7 +543,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -593,7 +593,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.14;
MACOSX_DEPLOYMENT_TARGET = 10.15;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
4 changes: 2 additions & 2 deletions intro_flutter_gpu/step_01/macos/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<!-- flutter_gpu requires Impeller -->
<key>FLTEnableImpeller</key>
<!-- Required for flutter_gpu -->
<key>FLTEnableFlutterGPU</key>
<true />
</dict>
</plist>
6 changes: 3 additions & 3 deletions intro_flutter_gpu/step_01/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: 'none'
version: 0.1.0

environment:
sdk: ^3.8.1
sdk: ^3.10.0-0

dependencies:
flutter:
Expand All @@ -13,12 +13,12 @@ dependencies:
sdk: flutter
flutter_gpu_shaders: ^0.3.0
native_assets_cli: ^0.13.0
vector_math: ^2.1.4
vector_math: ^2.2.0

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter_lints: ^6.0.0

flutter:
uses-material-design: true
Expand Down
2 changes: 1 addition & 1 deletion intro_flutter_gpu/step_01/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ void main() {
testWidgets('smoke test', (tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const MainApp());
}, skip: true); // See https://github.com/flutter/flutter/issues/171361
}, skip: true); // https://github.com/flutter/flutter/issues/173650
}
2 changes: 1 addition & 1 deletion intro_flutter_gpu/step_02/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ migrate_working_dir/
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.pub-cache/
.pub/
/build/
/coverage/

# Symbolication related
app.*.symbols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
android:label="intro_flutter_gpu"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<meta-data
android:name="io.flutter.embedding.android.EnableFlutterGPU"
android:value="true" />

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
5 changes: 4 additions & 1 deletion intro_flutter_gpu/step_02/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ allprojects {
}
}

val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get()
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)

subprojects {
Expand Down
1 change: 0 additions & 1 deletion intro_flutter_gpu/step_02/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
17 changes: 9 additions & 8 deletions intro_flutter_gpu/step_02/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
pluginManagement {
val flutterSdkPath = run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

Expand All @@ -18,7 +19,7 @@ pluginManagement {

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.3" apply false
id("com.android.application") version "8.9.1" apply false
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
Loading
Loading