Source:
public void start(long timeout) throws InstrumentsFailedToStartException, ApplicationCrashedOnStartException { boolean success = false; try { instruments.start(); if (version.getMajor() >= 6 && caps.getReuseContentAndSettings()) { long startTime = System.currentTimeMillis(); instruments.waitFor(10000); long endTime = System.currentTimeMillis(); if (endTime - startTime >= 10000) { throw new WebDriverException("Wait for instruments timed out. It probably means Apple has fixed this issue " + "and we can just get rid of the parent if block."); } instruments.start(); } Thread.sleep(2000); instrumentsPid = ClassicCommands.getHighestPidForName("instruments"); log.fine("waiting for registration request"); long waitStartTime = System.currentTimeMillis(); success = channel.waitForUIScriptToBeStarted(timeout); synchronized (this) { properlyStarted = success; } log.fine("registration request received" + session.getCachedCapabilityResponse()); if (!success) { log.warning("instruments crashed (" + ((System.currentTimeMillis() - waitStartTime) / 1000) + " sec)".toUpperCase()); instruments.waitFor(-1); if (instruments.getExitStatus() == 0) { throw new ApplicationCrashedOnStartException("Instruments did not start a session because the application crashed."); } else { throw new InstrumentsFailedToStartException( "Didn't get the capability back.Most likely, instruments crashed at startup."); } } } catch (InterruptedException e) { throw new InstrumentsFailedToStartException("instruments was interrupted while starting."); } finally { if (!success) { instruments.forceStop(); } } }

Target:
public void start(long timeout) throws InstrumentsFailedToStartException, ApplicationCrashedOnStartException { boolean success = false; try { instruments.start(); if (version.getMajor() >= 6 && caps.getReuseContentAndSettings()) { long startTime = System.currentTimeMillis(); instruments.waitFor(10000); long endTime = System.currentTimeMillis(); if (endTime - startTime >= 10000) { throw new WebDriverException("Wait for instruments timed out. It probably means Apple has fixed this issue " + "and we can just get rid of the parent if block."); } instruments.start(); } Thread.sleep(2000); instrumentsPid = ClassicCommands.getHighestPidForName("instruments"); log.fine("waiting for registration request"); long waitStartTime = System.currentTimeMillis(); success = channel.waitForUIScriptToBeStarted(timeout); synchronized (this) { properlyStarted = success; } log.fine("registration request received" + session.getCachedCapabilityResponse()); if (!success) { log.warning("instruments crashed (" + ((System.currentTimeMillis() - waitStartTime) / 1000) + " sec)".toUpperCase()); int exitStatus = instruments.waitFor((int)timeout*1000); if (exitStatus == 0) { throw new ApplicationCrashedOnStartException("Instruments did not start a session because the application crashed."); } else { throw new InstrumentsFailedToStartException( "Didn't get the capability back.Most likely, instruments crashed at startup."); } } } catch (InterruptedException e) { throw new InstrumentsFailedToStartException("instruments was interrupted while starting."); } finally { if (!success) { instruments.forceStop(); } } }