Skip to content

Commit 33a4c95

Browse files
author
Jonah Williams
authored
[flutter_tools] remove SkSL bundling and dump skp on compilation. (flutter#162849)
SkSL precompilation was only ever beneficial for iOS. For other platforms, we recommended against it as Skia generated shaders per target architecture which could be invalid on other devices. It is no longer possible to use Skia on iOS. Delete all Skia shader bundling logic. Fixes flutter#80091
1 parent c89d563 commit 33a4c95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+22
-918
lines changed

packages/flutter_tools/bin/macos_assemble.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,6 @@ BuildApp() {
168168
if [[ -n "$PERFORMANCE_MEASUREMENT_FILE" ]]; then
169169
flutter_args+=("--performance-measurement-file=${PERFORMANCE_MEASUREMENT_FILE}")
170170
fi
171-
if [[ -n "$BUNDLE_SKSL_PATH" ]]; then
172-
flutter_args+=("-dBundleSkSLPath=${BUNDLE_SKSL_PATH}")
173-
fi
174171
if [[ -n "$CODE_SIZE_DIRECTORY" ]]; then
175172
flutter_args+=("-dCodeSizeDirectory=${CODE_SIZE_DIRECTORY}")
176173
fi

packages/flutter_tools/bin/tool_backend.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Future<void> main(List<String> arguments) async {
2525
final String? localEngineHost = Platform.environment['LOCAL_ENGINE_HOST'];
2626
final String? projectDirectory = Platform.environment['PROJECT_DIR'];
2727
final String? splitDebugInfo = Platform.environment['SPLIT_DEBUG_INFO'];
28-
final String? bundleSkSLPath = Platform.environment['BUNDLE_SKSL_PATH'];
2928
final bool trackWidgetCreation = Platform.environment['TRACK_WIDGET_CREATION'] == 'true';
3029
final bool treeShakeIcons = Platform.environment['TREE_SHAKE_ICONS'] == 'true';
3130
final bool verbose = Platform.environment['VERBOSE_SCRIPT_LOGGING'] == 'true';
@@ -94,7 +93,6 @@ or
9493
'-dTargetFile=$flutterTarget',
9594
'-dTreeShakeIcons="$treeShakeIcons"',
9695
'-dDartObfuscation=$dartObfuscation',
97-
if (bundleSkSLPath != null) '-dBundleSkSLPath=$bundleSkSLPath',
9896
if (codeSizeDirectory != null) '-dCodeSizeDirectory=$codeSizeDirectory',
9997
if (splitDebugInfo != null) '-dSplitDebugInfo=$splitDebugInfo',
10098
if (dartDefines != null) '--DartDefines=$dartDefines',

packages/flutter_tools/bin/xcode_backend.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,6 @@ class Context {
475475
flutterArgs.add('-dCodesignIdentity=$expandedCodeSignIdentity');
476476
}
477477

478-
if (environment['BUNDLE_SKSL_PATH'] != null && environment['BUNDLE_SKSL_PATH']!.isNotEmpty) {
479-
flutterArgs.add('-dBundleSkSLPath=${environment['BUNDLE_SKSL_PATH']}');
480-
}
481-
482478
if (environment['CODE_SIZE_DIRECTORY'] != null &&
483479
environment['CODE_SIZE_DIRECTORY']!.isNotEmpty) {
484480
flutterArgs.add('-dCodeSizeDirectory=${environment['CODE_SIZE_DIRECTORY']}');

packages/flutter_tools/gradle/src/main/groovy/flutter.groovy

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,6 @@ class FlutterPlugin implements Plugin<Project> {
12201220
if (project.hasProperty(propDartDefines)) {
12211221
dartDefinesValue = project.property(propDartDefines)
12221222
}
1223-
String bundleSkSLPathValue
1224-
final String propBundleSkslPath = "bundle-sksl-path"
1225-
if (project.hasProperty(propBundleSkslPath)) {
1226-
bundleSkSLPathValue = project.property(propBundleSkslPath)
1227-
}
12281223
String performanceMeasurementFileValue
12291224
final String propPerformanceMeasurementFile = "performance-measurement-file"
12301225
if (project.hasProperty(propPerformanceMeasurementFile)) {
@@ -1316,7 +1311,6 @@ class FlutterPlugin implements Plugin<Project> {
13161311
treeShakeIcons(treeShakeIconsOptionsValue)
13171312
dartObfuscation(dartObfuscationValue)
13181313
dartDefines(dartDefinesValue)
1319-
bundleSkSLPath(bundleSkSLPathValue)
13201314
performanceMeasurementFile(performanceMeasurementFileValue)
13211315
codeSizeDirectory(codeSizeDirectoryValue)
13221316
deferredComponents(deferredComponentsValue)
@@ -1647,9 +1641,6 @@ abstract class BaseFlutterTask extends DefaultTask {
16471641
@Optional @Input
16481642
String dartDefines
16491643

1650-
@Optional @Input
1651-
String bundleSkSLPath
1652-
16531644
@Optional @Input
16541645
String codeSizeDirectory
16551646

@@ -1740,9 +1731,6 @@ abstract class BaseFlutterTask extends DefaultTask {
17401731
if (dartDefines != null) {
17411732
args("--DartDefines=${dartDefines}")
17421733
}
1743-
if (bundleSkSLPath != null) {
1744-
args("-dBundleSkSLPath=${bundleSkSLPath}")
1745-
}
17461734
if (codeSizeDirectory != null) {
17471735
args("-dCodeSizeDirectory=${codeSizeDirectory}")
17481736
}

packages/flutter_tools/lib/src/android/android_device.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -653,12 +653,6 @@ class AndroidDevice extends Device {
653653
if (debuggingOptions.traceSystrace) ...<String>['--ez', 'trace-systrace', 'true'],
654654
if (traceToFile != null) ...<String>['--es', 'trace-to-file', traceToFile],
655655
if (debuggingOptions.endlessTraceBuffer) ...<String>['--ez', 'endless-trace-buffer', 'true'],
656-
if (debuggingOptions.dumpSkpOnShaderCompilation) ...<String>[
657-
'--ez',
658-
'dump-skp-on-shader-compilation',
659-
'true',
660-
],
661-
if (debuggingOptions.cacheSkSL) ...<String>['--ez', 'cache-sksl', 'true'],
662656
if (debuggingOptions.purgePersistentCache) ...<String>[
663657
'--ez',
664658
'purge-persistent-cache',

packages/flutter_tools/lib/src/base/command_help.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ class CommandHelp {
4747
'debugDumpLayerTree',
4848
);
4949

50-
late final CommandHelpOption M = _makeOption(
51-
'M',
52-
'Write SkSL shaders to a unique file in the project directory.',
53-
);
54-
5550
late final CommandHelpOption P = _makeOption(
5651
'P',
5752
'Toggle performance overlay.',

packages/flutter_tools/lib/src/build_info.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class BuildInfo {
3535
this.splitDebugInfoPath,
3636
this.dartObfuscation = false,
3737
List<String>? dartDefines,
38-
this.bundleSkSLPath,
3938
List<String>? dartExperiments,
4039
required this.treeShakeIcons,
4140
this.performanceMeasurementFile,
@@ -118,11 +117,6 @@ class BuildInfo {
118117
/// Whether to apply dart source code obfuscation.
119118
final bool dartObfuscation;
120119

121-
/// An optional path to a JSON containing object SkSL shaders.
122-
///
123-
/// Currently this is only supported for Android builds.
124-
final String? bundleSkSLPath;
125-
126120
/// Additional constant values to be made available in the Dart program.
127121
///
128122
/// These values can be used with the const `fromEnvironment` constructors of
@@ -294,7 +288,6 @@ class BuildInfo {
294288
if (splitDebugInfoPath != null) kSplitDebugInfo: splitDebugInfoPath!,
295289
kTrackWidgetCreation: trackWidgetCreation.toString(),
296290
kIconTreeShakerFlag: treeShakeIcons.toString(),
297-
if (bundleSkSLPath != null) kBundleSkSLPath: bundleSkSLPath!,
298291
if (codeSizeDirectory != null) kCodeSizeDirectory: codeSizeDirectory!,
299292
if (fileSystemRoots.isNotEmpty) kFileSystemRoots: fileSystemRoots.join(','),
300293
if (fileSystemScheme != null) kFileSystemScheme: fileSystemScheme!,
@@ -323,7 +316,6 @@ class BuildInfo {
323316
'TREE_SHAKE_ICONS': treeShakeIcons.toString(),
324317
if (performanceMeasurementFile != null)
325318
'PERFORMANCE_MEASUREMENT_FILE': performanceMeasurementFile!,
326-
if (bundleSkSLPath != null) 'BUNDLE_SKSL_PATH': bundleSkSLPath!,
327319
'PACKAGE_CONFIG': packageConfigPath,
328320
if (codeSizeDirectory != null) 'CODE_SIZE_DIRECTORY': codeSizeDirectory!,
329321
if (flavor != null) 'FLAVOR': flavor!,
@@ -348,7 +340,6 @@ class BuildInfo {
348340
'-Ptree-shake-icons=$treeShakeIcons',
349341
if (performanceMeasurementFile != null)
350342
'-Pperformance-measurement-file=$performanceMeasurementFile',
351-
if (bundleSkSLPath != null) '-Pbundle-sksl-path=$bundleSkSLPath',
352343
if (codeSizeDirectory != null) '-Pcode-size-directory=$codeSizeDirectory',
353344
for (final String projectArg in androidProjectArgs) '-P$projectArg',
354345
];
@@ -975,9 +966,6 @@ const String kIconTreeShakerFlag = 'TreeShakeIcons';
975966
/// Controls whether a web build should use local canvaskit or the CDN
976967
const String kUseLocalCanvasKitFlag = 'UseLocalCanvasKit';
977968

978-
/// The input key for an SkSL bundle path.
979-
const String kBundleSkSLPath = 'BundleSkSLPath';
980-
981969
/// The define to pass build name
982970
const String kBuildName = 'BuildName';
983971

packages/flutter_tools/lib/src/build_system/targets/assets.dart

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import '../../artifacts.dart';
88
import '../../asset.dart';
99
import '../../base/common.dart';
1010
import '../../base/file_system.dart';
11-
import '../../base/logger.dart';
1211
import '../../build_info.dart';
13-
import '../../convert.dart';
1412
import '../../dart/package_map.dart';
1513
import '../../devfs.dart';
1614
import '../../flutter_manifest.dart';
@@ -42,17 +40,6 @@ Future<Depfile> copyAssets(
4240
List<File> additionalInputs = const <File>[],
4341
String? flavor,
4442
}) async {
45-
// Check for an SkSL bundle.
46-
final String? shaderBundlePath =
47-
environment.defines[kBundleSkSLPath] ?? environment.inputs[kBundleSkSLPath];
48-
final DevFSContent? skslBundle = processSkSLBundle(
49-
shaderBundlePath,
50-
engineVersion: environment.engineVersion,
51-
fileSystem: environment.fileSystem,
52-
logger: environment.logger,
53-
targetPlatform: targetPlatform,
54-
);
55-
5643
final File pubspecFile = environment.projectDir.childFile('pubspec.yaml');
5744
// Only the default asset bundle style is supported in assemble.
5845
final AssetBundle assetBundle =
@@ -121,12 +108,6 @@ Future<Depfile> copyAssets(
121108
),
122109
);
123110
}),
124-
if (skslBundle != null)
125-
kSkSLShaderBundlePath: AssetBundleEntry(
126-
skslBundle,
127-
kind: AssetKind.regular,
128-
transformers: const <AssetTransformerEntry>[],
129-
),
130111
};
131112

132113
await Future.wait<void>(
@@ -262,85 +243,9 @@ Future<Depfile> copyAssets(
262243
);
263244
}
264245
final Depfile depfile = Depfile(inputs + assetBundle.additionalDependencies, outputs);
265-
if (shaderBundlePath != null) {
266-
final File skSLBundleFile = environment.fileSystem.file(shaderBundlePath).absolute;
267-
depfile.inputs.add(skSLBundleFile);
268-
}
269246
return depfile;
270247
}
271248

272-
/// The path of the SkSL JSON bundle included in flutter_assets.
273-
const String kSkSLShaderBundlePath = 'io.flutter.shaders.json';
274-
275-
/// Validate and process an SkSL asset bundle in a [DevFSContent].
276-
///
277-
/// Returns `null` if the bundle was not provided, otherwise attempts to
278-
/// validate the bundle.
279-
///
280-
/// Throws [Exception] if the bundle is invalid due to formatting issues.
281-
///
282-
/// If the current target platform is different than the platform constructed
283-
/// for the bundle, a warning will be printed.
284-
DevFSContent? processSkSLBundle(
285-
String? bundlePath, {
286-
required TargetPlatform targetPlatform,
287-
required FileSystem fileSystem,
288-
required Logger logger,
289-
String? engineVersion,
290-
}) {
291-
if (bundlePath == null) {
292-
return null;
293-
}
294-
// Step 1: check that file exists.
295-
final File skSLBundleFile = fileSystem.file(bundlePath);
296-
if (!skSLBundleFile.existsSync()) {
297-
logger.printError('$bundlePath does not exist.');
298-
throw Exception('SkSL bundle was invalid.');
299-
}
300-
301-
// Step 2: validate top level bundle structure.
302-
Map<String, Object?>? bundle;
303-
try {
304-
final Object? rawBundle = json.decode(skSLBundleFile.readAsStringSync());
305-
if (rawBundle is Map<String, Object?>) {
306-
bundle = rawBundle;
307-
} else {
308-
logger.printError('"$bundle" was not a JSON object: $rawBundle');
309-
throw Exception('SkSL bundle was invalid.');
310-
}
311-
} on FormatException catch (err) {
312-
logger.printError('"$bundle" was not a JSON object: $err');
313-
throw Exception('SkSL bundle was invalid.');
314-
}
315-
// Step 3: Validate that:
316-
// * The engine revision the bundle was compiled with
317-
// is the same as the current revision.
318-
// * The target platform is the same (this one is a warning only).
319-
final String? bundleEngineRevision = bundle['engineRevision'] as String?;
320-
if (bundleEngineRevision != engineVersion) {
321-
logger.printError(
322-
'Expected Flutter $bundleEngineRevision, but found $engineVersion\n'
323-
'The SkSL bundle was produced with a different engine version. It must '
324-
'be recreated for the current Flutter version.',
325-
);
326-
throw Exception('SkSL bundle was invalid');
327-
}
328-
329-
final TargetPlatform? bundlePlatform = switch (bundle['platform'] as String?) {
330-
final String platform => getTargetPlatformForName(platform),
331-
null => null,
332-
};
333-
334-
if (bundlePlatform != targetPlatform) {
335-
logger.printError(
336-
'The SkSL bundle was created for $bundlePlatform, but the current '
337-
'platform is $targetPlatform. This may lead to less efficient shader '
338-
'caching.',
339-
);
340-
}
341-
return DevFSStringContent(json.encode(<String, Object?>{'data': bundle['data']}));
342-
}
343-
344249
/// Copy the assets defined in the flutter manifest into a build directory.
345250
class CopyAssets extends Target {
346251
const CopyAssets();

packages/flutter_tools/lib/src/commands/build_apk.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class BuildApkCommand extends BuildSubCommand {
2929
addDartObfuscationOption();
3030
usesDartDefineOption();
3131
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
32-
addBundleSkSLPathOption(hide: !verboseHelp);
3332
addEnableExperimentation(hide: !verboseHelp);
3433
addBuildPerformanceFile(hide: !verboseHelp);
3534
addNullSafetyModeOptions(hide: !verboseHelp);

packages/flutter_tools/lib/src/commands/build_appbundle.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class BuildAppBundleCommand extends BuildSubCommand {
3232
addDartObfuscationOption();
3333
usesDartDefineOption();
3434
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
35-
addBundleSkSLPathOption(hide: !verboseHelp);
3635
addBuildPerformanceFile(hide: !verboseHelp);
3736
usesTrackWidgetCreation(verboseHelp: verboseHelp);
3837
addNullSafetyModeOptions(hide: !verboseHelp);

0 commit comments

Comments
 (0)