Skip to content

Commit f31202e

Browse files
authored
[flutter_tools] Handle WDAC block error code 4551 for impellerc (flutter#190108)
[flutter_tools] Handle WDAC block error code 4551 for impellerc On Windows, when impellerc is blocked by Windows Defender Application Control (WDAC), it throws a ProcessException with error code 4551. Define the constant for this error code next to the existing code 1260 and check for it in ShaderCompiler._isBlockedBySecurityPolicy to exit gracefully. Fixes flutter#190232
1 parent 62df701 commit f31202e

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎packages/flutter_tools/lib/src/build_system/tools/shader_compiler.dart‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ class ShaderCompiler {
336336
return false;
337337
}
338338
const winErrorAccessDisabledByPolicy = 1260;
339-
return exception.errorCode == winErrorAccessDisabledByPolicy;
339+
const winErrorSystemIntegrityPolicyViolation = 4551;
340+
return exception.errorCode == winErrorAccessDisabledByPolicy ||
341+
exception.errorCode == winErrorSystemIntegrityPolicyViolation;
340342
}
341343

342344
void _logSecurityBlockError(String impellercPath) {

‎packages/flutter_tools/test/general.shard/build_system/targets/shader_compiler_test.dart‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,54 @@ void main() {
830830
},
831831
);
832832

833+
testWithoutContext(
834+
'compileShader throws ToolExit and logs friendly message when impellerc is blocked by WDAC (4551) '
835+
'(regression test for https://github.com/flutter/flutter/issues/190232)',
836+
() async {
837+
final blockedException = ProcessException(
838+
impellerc,
839+
<String>[],
840+
'An Application Control policy has blocked this file',
841+
4551,
842+
);
843+
final processManager = FakeProcessManager.list(<FakeCommand>[
844+
FakeCommand(
845+
command: <String>[
846+
impellerc,
847+
'--runtime-stage-metal',
848+
'--iplr',
849+
'--sl=$outputPath',
850+
'--spirv=$outputPath.spirv',
851+
'--input=$fragPath',
852+
'--input-type=frag',
853+
'--include=$fragDir',
854+
'--include=$shaderLibDir',
855+
],
856+
exception: blockedException,
857+
),
858+
]);
859+
final shaderCompiler = ShaderCompiler(
860+
processManager: processManager,
861+
logger: logger,
862+
fileSystem: fileSystem,
863+
artifacts: artifacts,
864+
platform: FakePlatform(operatingSystem: 'windows'),
865+
);
866+
867+
await expectLater(
868+
shaderCompiler.compileShader(
869+
input: fileSystem.file(fragPath),
870+
outputPath: outputPath,
871+
targetPlatform: TargetPlatform.ios,
872+
),
873+
throwsToolExit(message: 'Impeller shader compiler was blocked by security policy.'),
874+
);
875+
876+
expect(logger.errorText, contains('blocked by system'));
877+
expect(logger.errorText, contains(impellerc));
878+
},
879+
);
880+
833881
testWithoutContext(
834882
'compileShader throws ToolExit and logs friendly message when impellerc is blocked by group policy',
835883
() async {

0 commit comments

Comments
 (0)