Skip to content

Commit 1cfdac4

Browse files
Always invoke impeller ios shader target (#114451)
1 parent db381d7 commit 1cfdac4

File tree

2 files changed

+75
-11
lines changed
  • packages/flutter_tools

2 files changed

+75
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -511,22 +511,14 @@ abstract class IosAssetBundle extends Target {
511511

512512
final FlutterProject flutterProject = FlutterProject.fromDirectory(environment.projectDir);
513513

514-
bool isImpellerEnabled() {
515-
if (!flutterProject.ios.infoPlist.existsSync()) {
516-
return false;
517-
}
518-
final Map<String, Object> info = globals.plistParser.parseFile(flutterProject.ios.infoPlist.path);
519-
520-
final Object? enableImpeller = info['FLTEnableImpeller'];
521-
return enableImpeller is bool && enableImpeller;
522-
}
523-
524514
// Copy the assets.
525515
final Depfile assetDepfile = await copyAssets(
526516
environment,
527517
assetDirectory,
528518
targetPlatform: TargetPlatform.ios,
529-
shaderTarget: isImpellerEnabled() ? ShaderTarget.impelleriOS : ShaderTarget.sksl,
519+
// Always specify an impeller shader target so that we support runtime toggling and
520+
// the --enable-impeller debug flag.
521+
shaderTarget: ShaderTarget.impelleriOS,
530522
additionalInputs: <File>[
531523
flutterProject.ios.infoPlist,
532524
flutterProject.ios.appFrameworkInfoPlist,

packages/flutter_tools/test/general.shard/build_system/targets/ios_test.dart

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,78 @@ void main() {
217217
expect(assetDirectory.childFile('isolate_snapshot_data'), exists);
218218
expect(assetDirectory.childFile('io.flutter.shaders.json'), exists);
219219
expect(assetDirectory.childFile('io.flutter.shaders.json').readAsStringSync(), '{"data":{"A":"B"}}');
220+
}, overrides: <Type, Generator>{
221+
FileSystem: () => fileSystem,
222+
ProcessManager: () => processManager,
223+
Platform: () => macPlatform,
224+
});
225+
226+
testUsingContext('DebugIosApplicationBundle with impeller and shader compilation', () async {
227+
// Create impellerc to work around fallback detection logic.
228+
fileSystem.file(artifacts.getHostArtifact(HostArtifact.impellerc)).createSync(recursive: true);
229+
230+
environment.defines[kBuildMode] = 'debug';
231+
environment.defines[kCodesignIdentity] = 'ABC123';
232+
// Precompiled dart data
233+
234+
fileSystem.file(artifacts.getArtifactPath(Artifact.vmSnapshotData, mode: BuildMode.debug))
235+
.createSync();
236+
fileSystem.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
237+
.createSync();
238+
// Project info
239+
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
240+
fileSystem.file('.packages').writeAsStringSync('\n');
241+
// Plist file
242+
fileSystem.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
243+
.createSync(recursive: true);
244+
// Shader file
245+
fileSystem.file('shader.glsl').writeAsStringSync('test');
246+
// App kernel
247+
environment.buildDir.childFile('app.dill').createSync(recursive: true);
248+
// Stub framework
249+
environment.buildDir
250+
.childDirectory('App.framework')
251+
.childFile('App')
252+
.createSync(recursive: true);
253+
254+
final Directory frameworkDirectory = environment.outputDir.childDirectory('App.framework');
255+
final File frameworkDirectoryBinary = frameworkDirectory.childFile('App');
256+
processManager.addCommands(<FakeCommand>[
257+
const FakeCommand(command: <String>[
258+
'HostArtifact.impellerc',
259+
'--runtime-stage-metal',
260+
'--iplr',
261+
'--sl=/App.framework/flutter_assets/shader.glsl',
262+
'--spirv=/App.framework/flutter_assets/shader.glsl.spirv',
263+
'--input=/shader.glsl',
264+
'--input-type=frag',
265+
'--include=/'
266+
]),
267+
FakeCommand(command: <String>[
268+
'codesign',
269+
'--force',
270+
'--sign',
271+
'ABC123',
272+
'--timestamp=none',
273+
frameworkDirectoryBinary.path,
274+
]),
275+
]);
276+
277+
await const DebugIosApplicationBundle().build(environment);
278+
expect(processManager, hasNoRemainingExpectations);
279+
280+
expect(frameworkDirectoryBinary, exists);
281+
expect(frameworkDirectory.childFile('Info.plist'), exists);
282+
283+
final Directory assetDirectory = frameworkDirectory.childDirectory('flutter_assets');
284+
expect(assetDirectory.childFile('kernel_blob.bin'), exists);
285+
expect(assetDirectory.childFile('AssetManifest.json'), exists);
286+
expect(assetDirectory.childFile('vm_snapshot_data'), exists);
287+
expect(assetDirectory.childFile('isolate_snapshot_data'), exists);
288+
}, overrides: <Type, Generator>{
289+
FileSystem: () => fileSystem,
290+
ProcessManager: () => processManager,
291+
Platform: () => macPlatform,
220292
});
221293

222294
testUsingContext('ReleaseIosApplicationBundle build', () async {

0 commit comments

Comments
 (0)