Commit c5567a5f authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Fix race condition locating observatory port on iOS (#6090)

Ensure that we're monitoring logs before we launch the app on the
device. This prevents the case where we start monitoring after the ports
have already been logged.

Also update the regex to use an optional capture group.
parent c2386fb7
......@@ -249,6 +249,16 @@ class IOSDevice extends Device {
// ports post launch.
printTrace("Debugging is enabled, connecting to observatory and the diagnostic server");
Future<int> forwardObsPort = _acquireAndForwardPort(ProtocolDiscovery.kObservatoryService,
debuggingOptions.observatoryPort);
Future<int> forwardDiagPort;
if (debuggingOptions.buildMode == BuildMode.debug) {
forwardDiagPort = _acquireAndForwardPort(ProtocolDiscovery.kDiagnosticService,
debuggingOptions.diagnosticPort);
} else {
forwardDiagPort = new Future<int>.value(null);
}
Future<int> launch = runCommandAndStreamOutput(launchCommand, trace: true);
List<int> ports = await launch.then((int result) async {
......@@ -260,17 +270,6 @@ class IOSDevice extends Device {
}
printTrace("Application launched on the device. Attempting to forward ports.");
Future<int> forwardObsPort = _acquireAndForwardPort(ProtocolDiscovery.kObservatoryService,
debuggingOptions.observatoryPort);
Future<int> forwardDiagPort;
if (debuggingOptions.buildMode == BuildMode.debug) {
forwardDiagPort = _acquireAndForwardPort(ProtocolDiscovery.kDiagnosticService,
debuggingOptions.diagnosticPort);
} else {
forwardDiagPort = new Future<int>.value(null);
}
return Future.wait(<Future<int>>[forwardObsPort, forwardDiagPort]);
});
......@@ -435,7 +434,7 @@ class _IOSDeviceLogReader extends DeviceLogReader {
//
// iOS 9 format: Runner[297] <Notice>:
// iOS 10 format: Runner(libsystem_asl.dylib)[297] <Notice>:
static final RegExp _runnerRegex = new RegExp(r'Runner[(.*)]\[[\d]+\] <[A-Za-z]+>: ');
static final RegExp _runnerRegex = new RegExp(r'Runner(\(.*\))?\[[\d]+\] <[A-Za-z]+>: ');
void _onLine(String line) {
Match match = _runnerRegex.firstMatch(line);
......
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