Unverified Commit 29736f6f authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tools] Put a heap size limit on the frontend_server (#58039)

parent e7661905
...@@ -263,6 +263,11 @@ class KernelCompiler { ...@@ -263,6 +263,11 @@ class KernelCompiler {
} }
final List<String> command = <String>[ final List<String> command = <String>[
engineDartPath, engineDartPath,
'--disable-dart-dev',
// This limit is in place to help track down
// https://github.com/flutter/flutter/issues/54420. It should be removed
// when the underlying issue is identified and fixed.
'--old_gen_heap_size=2000',
frontendServer, frontendServer,
'--sdk-root', '--sdk-root',
sdkRoot, sdkRoot,
...@@ -648,6 +653,11 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -648,6 +653,11 @@ class DefaultResidentCompiler implements ResidentCompiler {
); );
final List<String> command = <String>[ final List<String> command = <String>[
globals.artifacts.getArtifactPath(Artifact.engineDartBinary), globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
// This limit is in place to help track down
// https://github.com/flutter/flutter/issues/54420. It should be removed
// when the underlying issue is identified and fixed.
'--old_gen_heap_size=2000',
frontendServer, frontendServer,
'--sdk-root', '--sdk-root',
sdkRoot, sdkRoot,
......
...@@ -86,6 +86,8 @@ void main() { ...@@ -86,6 +86,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -115,6 +117,8 @@ void main() { ...@@ -115,6 +117,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -144,6 +148,8 @@ void main() { ...@@ -144,6 +148,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -174,6 +180,8 @@ void main() { ...@@ -174,6 +180,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -206,6 +214,8 @@ void main() { ...@@ -206,6 +214,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -236,6 +246,8 @@ void main() { ...@@ -236,6 +246,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
...@@ -278,6 +290,8 @@ void main() { ...@@ -278,6 +290,8 @@ void main() {
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
FakeCommand(command: <String>[ FakeCommand(command: <String>[
artifacts.getArtifactPath(Artifact.engineDartBinary), artifacts.getArtifactPath(Artifact.engineDartBinary),
'--disable-dart-dev',
'--old_gen_heap_size=2000',
artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk),
'--sdk-root', '--sdk-root',
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/', artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath) + '/',
......
...@@ -76,6 +76,37 @@ void main() { ...@@ -76,6 +76,37 @@ void main() {
Platform: kNoColorTerminalPlatform, Platform: kNoColorTerminalPlatform,
}); });
testUsingContext('passes VM heap size limit', () async {
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
Future<List<int>>.value(utf8.encode(
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'
))
));
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart',
buildMode: BuildMode.debug,
trackWidgetCreation: false,
dartDefines: const <String>[],
packageConfig: PackageConfig.empty,
packagesPath: '.packages',
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(testLogger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
final VerificationResult argVerification = verify(mockProcessManager.start(captureAny));
expect(argVerification.captured.single, containsAll(<String>[
'--disable-dart-dev',
'--old_gen_heap_size=2000',
]));
}, overrides: <Type, Generator>{
ProcessManager: () => mockProcessManager,
OutputPreferences: () => OutputPreferences(showColor: false),
Platform: kNoColorTerminalPlatform,
});
testUsingContext('passes correct AOT config to kernel compiler in aot/profile mode', () async { testUsingContext('passes correct AOT config to kernel compiler in aot/profile mode', () async {
when(mockFrontendServer.stdout) when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture( .thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment