MobileNativeFoundation / bluepill

Bluepill is a reliable iOS testing tool that runs UI tests using multiple simulators on a single machine
BSD 2-Clause "Simplified" License
3.18k stars 231 forks source link

Proper shutdown mechanism #559

Closed nanwng closed 10 months ago

nanwng commented 10 months ago

We were seeing lots of test timeout issues on macOS Ventura machines. It turned out that there's some shutdown error for simulators causing hanging bp processes. See below log for example:

{24164} 20230825.132813 [  ERROR ] (BP-1) Timeout: [Attempt 1] Create Simulator
{24164} 20230825.132813 [  ERROR ] (BP-1) The operation couldn’t be completed. (org.linkedin.bluepill.ErrorDomain error -1.)
{24164} 20230825.132813 [  INFO  ] (BP-1) Relaunching the simulator due to a BAD STATE
{24164} 20230825.132813 [  INFO  ] (BP-1) [Attempt 1] Delete Simulator
{24164} 20230825.132813 [  INFO  ] (BP-1) Shutting down Simulator
{24164} 20230825.132859 [  INFO  ] (BP-1) Simulator 0F53DAFD-72C0-4B9C-8DA0-6975202DBB28 achieved the BOOTED state Booted
{24164} 20230825.132900 [  INFO  ] (BP-1) Completed: [Attempt 1] Delete Simulator 0F53DAFD-72C0-4B9C-8DA0-6975202DBB28
{24164} 20230825.132900 [  ERROR ] (BP-1) EndTimerFailure: EndTimer called without starting a timer for 'Simulator 0F53DAFD-72C0-4B9C-8DA0-6975202DBB28'
{24164} 20230825.132900 [  INFO  ] (BP-1) [Attempt 1] Create Simulator
{24164} 20230825.132900 [  INFO  ] (BP-1) Booting a simulator without launching Simulator app
{24164} 20230825.133118 [  ERROR ] (BP-1) Simulator 354C7BB2-724C-4BEE-A966-29CF01B867B9 failed to boot. State: Shutdown
{24164} 20230825.133118 [  ERROR ] (BP-1) Shutting down Simulator failed: Unable to shutdown device in current state: Shutdown
{24164} 20230825.133118 [  ERROR ] (BP-1) Completed: [Attempt 1] Create Simulator 354C7BB2-724C-4BEE-A966-29CF01B867B9
{24164} 20230825.133118 [  ERROR ] (BP-1) Unable to boot the Simulator.
{24164} 20230825.133118 [  INFO  ] (BP-1) [Attempt 1] Delete Simulator
{24164} 20230825.133118 [  INFO  ] (BP-1) Shutting down Simulator
{24164} 20230825.133118 [  ERROR ] (BP-1) Shutting down Simulator failed: Unable to shutdown device in current state: Shutdown
{24164} 20230825.133118 [  ERROR ] (BP-1) Completed: [Attempt 1] Delete Simulator 354C7BB2-724C-4BEE-A966-29CF01B867B9
{24164} 20230825.133118 [  ERROR ] (BP-1) Unable to shutdown device in current state: Shutdown
{24164} 20230825.133118 [  INFO  ] (BP-1) Attempt's Exit Status: BPExitStatusSimulatorCreationFailed, Bundle exit status: BPExitStatusSimulatorCreationFailed
{24164} 20230825.133118 [  INFO  ] (BP-1) Exit Status: BPExitStatusSimulatorCreationFailed
{24164} 20230825.133118 [  INFO  ] (BP-1) Failure Tolerance: 1
{24164} 20230825.133118 [  INFO  ] (BP-1) Retry count: 1
{24164} 20230825.133118 [  INFO  ] (BP-1) Recovering from tooling problem

Fixing this by not calling the private shutdown api when the simulator is already in the shutdown state.