--trace-startup: non-zero exit code when fails; enable in iOS runtime (#5309)
This commit is contained in:
@@ -275,7 +275,7 @@ Future<int> startApp(
|
||||
Observatory observatory = await Observatory.connect(result.observatoryPort);
|
||||
await downloadStartupTrace(observatory);
|
||||
} catch (error) {
|
||||
printError('Error connecting to observatory: $error');
|
||||
printError('Error downloading trace from observatory: $error');
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,11 @@ class Tracing {
|
||||
/// Download the startup trace information from the given observatory client and
|
||||
/// store it to build/start_up_info.json.
|
||||
Future<Null> downloadStartupTrace(Observatory observatory) async {
|
||||
File traceInfoFile = new File('build/start_up_info.json');
|
||||
|
||||
if (await traceInfoFile.exists())
|
||||
await traceInfoFile.delete();
|
||||
|
||||
Tracing tracing = new Tracing(observatory);
|
||||
|
||||
Map<String, dynamic> timeline = await tracing.stopTracingAndDownloadTimeline(
|
||||
@@ -173,16 +178,13 @@ Future<Null> downloadStartupTrace(Observatory observatory) async {
|
||||
int firstFrameTimestampMicros = extractInstantEventTimestamp(kFirstUsefulFrameEventName);
|
||||
|
||||
if (engineEnterTimestampMicros == null) {
|
||||
printError('Engine start event is missing in the timeline. Cannot compute startup time.');
|
||||
return null;
|
||||
throw 'Engine start event is missing in the timeline. Cannot compute startup time.';
|
||||
}
|
||||
|
||||
if (firstFrameTimestampMicros == null) {
|
||||
printError('First frame event is missing in the timeline. Cannot compute startup time.');
|
||||
return null;
|
||||
throw 'First frame event is missing in the timeline. Cannot compute startup time.';
|
||||
}
|
||||
|
||||
File traceInfoFile = new File('build/start_up_info.json');
|
||||
int timeToFirstFrameMicros = firstFrameTimestampMicros - engineEnterTimestampMicros;
|
||||
Map<String, dynamic> traceInfo = <String, dynamic>{
|
||||
'engineEnterTimestampMicros': engineEnterTimestampMicros,
|
||||
|
||||
@@ -216,6 +216,9 @@ class IOSDevice extends Device {
|
||||
// the port picked and scrape that later.
|
||||
}
|
||||
|
||||
if (platformArgs['trace-startup'] ?? false)
|
||||
launchArguments.add('--trace-startup');
|
||||
|
||||
List<String> launchCommand = <String>[
|
||||
'/usr/bin/env',
|
||||
'ios-deploy',
|
||||
|
||||
@@ -188,7 +188,12 @@ class RunAndStayResident extends ResidentRunner {
|
||||
|
||||
if (serviceProtocol != null && traceStartup) {
|
||||
printStatus('Downloading startup trace info...');
|
||||
await downloadStartupTrace(serviceProtocol);
|
||||
try {
|
||||
await downloadStartupTrace(serviceProtocol);
|
||||
} catch(error) {
|
||||
printError(error);
|
||||
return 2;
|
||||
}
|
||||
appFinished();
|
||||
} else {
|
||||
setupTerminal();
|
||||
|
||||
Reference in New Issue
Block a user