Commit 240e499b authored by Devon Carew's avatar Devon Carew

Merge pull request #2219 from devoncarew/speed_up_start

some performance optimizations for starting apps
parents c04b4c75 8c95500e
...@@ -46,12 +46,12 @@ class ListenCommand extends RunCommandBase { ...@@ -46,12 +46,12 @@ class ListenCommand extends RunCommandBase {
applicationPackages, applicationPackages,
toolchain, toolchain,
buildConfigurations, buildConfigurations,
target: argResults['target'], target: target,
install: firstTime, install: firstTime,
stop: true, stop: true,
checked: argResults['checked'], checked: checked,
traceStartup: argResults['trace-startup'], traceStartup: traceStartup,
route: argResults['route'] route: route
); );
firstTime = false; firstTime = false;
} while (!singleRun && result == 0 && _watchDirectory(watchCommand)); } while (!singleRun && result == 0 && _watchDirectory(watchCommand));
......
...@@ -65,7 +65,7 @@ class RunCommand extends RunCommandBase { ...@@ -65,7 +65,7 @@ class RunCommand extends RunCommandBase {
RunCommand() { RunCommand() {
argParser.addFlag('full-restart', argParser.addFlag('full-restart',
defaultsTo: true, defaultsTo: false,
help: 'Stop any currently running application process before starting the app.'); help: 'Stop any currently running application process before starting the app.');
argParser.addFlag('clear-logs', argParser.addFlag('clear-logs',
defaultsTo: true, defaultsTo: true,
...@@ -116,13 +116,13 @@ class RunCommand extends RunCommandBase { ...@@ -116,13 +116,13 @@ class RunCommand extends RunCommandBase {
applicationPackages, applicationPackages,
toolchain, toolchain,
buildConfigurations, buildConfigurations,
target: argResults['target'], target: target,
enginePath: runner.enginePath, enginePath: runner.enginePath,
install: true, install: true,
stop: argResults['full-restart'], stop: argResults['full-restart'],
checked: argResults['checked'], checked: checked,
traceStartup: argResults['trace-startup'], traceStartup: traceStartup,
route: argResults['route'], route: route,
clearLogs: clearLogs, clearLogs: clearLogs,
startPaused: argResults['start-paused'], startPaused: argResults['start-paused'],
debugPort: debugPort debugPort: debugPort
...@@ -140,7 +140,7 @@ Future<int> startApp( ...@@ -140,7 +140,7 @@ Future<int> startApp(
List<BuildConfiguration> configs, { List<BuildConfiguration> configs, {
String target, String target,
String enginePath, String enginePath,
bool stop: true, bool stop: false,
bool install: true, bool install: true,
bool checked: true, bool checked: true,
bool traceStartup: false, bool traceStartup: false,
......
...@@ -148,9 +148,7 @@ bool _addAssetFile(Archive archive, _Asset asset) { ...@@ -148,9 +148,7 @@ bool _addAssetFile(Archive archive, _Asset asset) {
return false; return false;
} }
List<int> content = file.readAsBytesSync(); List<int> content = file.readAsBytesSync();
archive.addFile( archive.addFile(new ArchiveFile.noCompress(asset.key, content.length, content));
new ArchiveFile.noCompress(asset.key, content.length, content)
);
return true; return true;
} }
...@@ -287,14 +285,19 @@ Future<int> assemble({ ...@@ -287,14 +285,19 @@ Future<int> assemble({
if (fontManifest != null) if (fontManifest != null)
archive.addFile(fontManifest); archive.addFile(fontManifest);
printTrace('Calling CipherParameters.seedRandom().');
CipherParameters.get().seedRandom();
AsymmetricKeyPair keyPair = keyPairFromPrivateKeyFileSync(privateKeyPath); AsymmetricKeyPair keyPair = keyPairFromPrivateKeyFileSync(privateKeyPath);
printTrace('KeyPair from $privateKeyPath: $keyPair.'); printTrace('KeyPair from $privateKeyPath: $keyPair.');
if (keyPair != null) {
printTrace('Calling CipherParameters.seedRandom().');
CipherParameters.get().seedRandom();
}
printTrace('Encoding zip file.'); printTrace('Encoding zip file.');
Uint8List zipBytes = new Uint8List.fromList(new ZipEncoder().encode(archive)); Uint8List zipBytes = new Uint8List.fromList(new ZipEncoder().encode(archive));
ensureDirectoryExists(outputPath); ensureDirectoryExists(outputPath);
printTrace('Creating flx at $outputPath.'); printTrace('Creating flx at $outputPath.');
Bundle bundle = new Bundle.fromContent( Bundle bundle = new Bundle.fromContent(
path: outputPath, path: outputPath,
...@@ -303,5 +306,8 @@ Future<int> assemble({ ...@@ -303,5 +306,8 @@ Future<int> assemble({
keyPair: keyPair keyPair: keyPair
); );
bundle.writeSync(); bundle.writeSync();
printTrace('Built and signed flx at $outputPath.');
return 0; return 0;
} }
...@@ -32,7 +32,9 @@ class IOSSimulators extends PollingDeviceDiscovery { ...@@ -32,7 +32,9 @@ class IOSSimulators extends PollingDeviceDiscovery {
class IOSSimulatorUtils { class IOSSimulatorUtils {
/// Returns [IOSSimulatorUtils] active in the current app context (i.e. zone). /// Returns [IOSSimulatorUtils] active in the current app context (i.e. zone).
static IOSSimulatorUtils get instance => context[IOSSimulatorUtils] ?? (context[IOSSimulatorUtils] = new IOSSimulatorUtils()); static IOSSimulatorUtils get instance {
return context[IOSSimulatorUtils] ?? (context[IOSSimulatorUtils] = new IOSSimulatorUtils());
}
List<IOSSimulator> getAttachedDevices() { List<IOSSimulator> getAttachedDevices() {
if (!xcode.isInstalledAndMeetsVersionCheck) if (!xcode.isInstalledAndMeetsVersionCheck)
...@@ -238,12 +240,7 @@ class IOSSimulator extends Device { ...@@ -238,12 +240,7 @@ class IOSSimulator extends Device {
} }
} }
@override bool isConnected() => Platform.isMacOS;
bool isConnected() {
if (!Platform.isMacOS)
return false;
return SimControl.instance.getConnectedDevices().any((SimDevice device) => device.udid == id);
}
@override @override
bool isSupported() { bool isSupported() {
......
...@@ -9,8 +9,8 @@ import 'dart:typed_data'; ...@@ -9,8 +9,8 @@ import 'dart:typed_data';
import 'package:asn1lib/asn1lib.dart'; import 'package:asn1lib/asn1lib.dart';
import 'package:bignum/bignum.dart'; import 'package:bignum/bignum.dart';
import 'package:pointycastle/pointycastle.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:pointycastle/pointycastle.dart';
export 'package:pointycastle/pointycastle.dart' show AsymmetricKeyPair; export 'package:pointycastle/pointycastle.dart' show AsymmetricKeyPair;
...@@ -82,8 +82,11 @@ Uint8List serializeManifest(Map manifestDescriptor, ECPublicKey publicKey, Uint8 ...@@ -82,8 +82,11 @@ Uint8List serializeManifest(Map manifestDescriptor, ECPublicKey publicKey, Uint8
if (publicKey != null) if (publicKey != null)
outputManifest['key'] = BASE64.encode(publicKey.Q.getEncoded()); outputManifest['key'] = BASE64.encode(publicKey.Q.getEncoded());
Uint8List zipHash = new Digest(_params.hashAlgorithm).process(zipBytes); SHA256 sha = new SHA256();
BigInteger zipHashInt = new BigInteger.fromBytes(1, zipHash); sha.add(zipBytes);
List<int> hash = sha.close();
BigInteger zipHashInt = new BigInteger.fromBytes(1, hash);
outputManifest['content-hash'] = zipHashInt.intValue(); outputManifest['content-hash'] = zipHashInt.intValue();
return new Uint8List.fromList(UTF8.encode(JSON.encode(outputManifest))); return new Uint8List.fromList(UTF8.encode(JSON.encode(outputManifest)));
......
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