Skip to content

Commit

Permalink
make safari real devices work with new commandProxy model (fix #3376)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps committed Aug 22, 2014
1 parent 883d555 commit 064cf71
Showing 1 changed file with 42 additions and 23 deletions.
65 changes: 42 additions & 23 deletions lib/devices/ios/ios.js
Expand Up @@ -294,29 +294,48 @@ IOS.prototype.startInstruments = function (cb) {
});
}.bind(this);

logger.debug("Starting command proxy.");
this.commandProxy.start(
function (err) { // on first connection
// first let instruments know so that it does not restart itself
this.instruments.launchHandler(err);
// then we call the callback
cb(err);
}.bind(this)
//
, function (err) { // regular cb
if (err) return treatError(err, cb);
logger.debug("Starting instruments");
this.instruments.start(
function (err) {
if (err) return treatError(err, cb);
// we don't call cb here, waiting for first connection or error
}.bind(this)
, function (code) {
this.onUnexpectedInstrumentsExit(code);
}.bind(this)
);
}.bind(this)
);
if (this.shouldIgnoreInstrumentsExit()) {
// for safari on a real device, instruments is going to crash, but we
// expect that and ignore it
logger.debug("Not starting command proxy since we're expecting that " +
"Instruments won't be able to talk to it anyway");
this.instruments.start(
function (err) {
if (err) return treatError(err, cb);
// instruments will never check into the command proxy, so go ahead
// and just call back here once instruments is started, rather than
// waiting for it to make the first connection to the command proxy
cb();
}
, function () {
// ignore unexpected instruments exit since that's exactly what
// we're expecting anyway
});
} else {
logger.debug("Starting command proxy.");
this.commandProxy.start(
function (err) { // on first connection
// first let instruments know so that it does not restart itself
this.instruments.launchHandler(err);
// then we call the callback
cb(err);
}.bind(this)
//
, function (err) { // regular cb
if (err) return treatError(err, cb);
logger.debug("Starting instruments");
this.instruments.start(
function (err) {
if (err) return treatError(err, cb);
// we don't call cb here, waiting for first connection or error
}.bind(this)
, function (code) {
this.onUnexpectedInstrumentsExit(code);
}.bind(this)
);
}.bind(this)
);
}
};

IOS.prototype.makeInstruments = function (cb) {
Expand Down

0 comments on commit 064cf71

Please sign in to comment.