Commit a0aa0edf authored by Yegor's avatar Yegor Committed by GitHub

--trace-startup: non-zero exit code when fails; enable in iOS runtime (#5309)

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