Source:
<code>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()); <START> instruments.waitFor(-1); <END> 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(); } } }</code><technical_language>This is infinite wait, a blocking call. waitForUIScriptToBeStarted failed, is script time start is hung. In case this wait for eternity. Wait a timeout instead timeout throw InstrumentsFailedToStartException</technical_language>

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(); } } }