danielpaulus / go-ios

This is an operating system independent implementation of iOS device features. You can run UI tests, launch or kill apps, install apps etc. with it.
MIT License
935 stars 181 forks source link

An error when we repeat the commands to launch and kill the app a large number of times #223

Open sanja12 opened 1 year ago

sanja12 commented 1 year ago

Hi, I am using go-ios v1.0.99 to test iOS app. Due to the large number and types of tests, it is necessary to launch and kill the app many times. The launch and kill commands are repeated one after the other. At some point it is no longer possible to kill the application and the error I get is attached. When an error occurs, the application can no longer be killed or launched, and the "ios reboot ..." command does not work either. The only way to fix this is to manually reconnect the phone cable and in that way refresh the connection between the iPhone and XCode. Manually rebooting the phone does not help.

To Reproduce Steps to reproduce the behavior:

  1. ios launch ...
  2. ios kill ...
  3. Repeat the steps 1 and 2 30-100 times

Expected behavior App is launched/killed

I'm working with: Windows 10 Enterprise 21H2 / 64 bits and iPhone X, iOS 15.6.1

Error {"level":"debug","msg":"Looking for device \'udid\'","time":"2023-01-26T10:59:23+01:00"}\n{"level":"debug","msg":"Failed connecting to com.apple.instruments.remoteserver, trying com.apple.instruments.remoteserver.DVTSecureSocketProxy","time":"2023-01-26T10:59:23+01:00"}\n{"EnableServiceSSL":true,"Port":53638,"Request":"StartService","Service":"com.apple.instruments.remoteserver.DVTSecureSocketProxy","level":"debug","msg":"Service started on device","time":"2023-01-26T10:59:23+01:00"}\n{"channel_id":"com.apple.instruments.server.services.processcontrol","level":"debug","msg":"Requesting channel","time":"2023-01-26T10:59:23+01:00"}\n{"level":"debug","msg":"i5.1 c0 t:Ack mlen:16 aux_len0 paylen0","time":"2023-01-26T10:59:23+01:00"}\n{"channel_id":"com.apple.instruments.server.services.processcontrol","level":"debug","msg":"Channel open","time":"2023-01-26T10:59:23+01:00"}\n{"EnableServiceSSL":false,"Port":53641,"Request":"StartService","Service":"com.apple.mobile.installation_proxy","level":"debug","msg":"Service started on device","time":"2023-01-26T10:59:23+01:00"}\n{"level":"debug","msg":"Failed connecting to com.apple.instruments.remoteserver, trying com.apple.instruments.remoteserver.DVTSecureSocketProxy","time":"2023-01-26T10:59:23+01:00"}\n{"EnableServiceSSL":true,"Port":53645,"Request":"StartService","Service":"com.apple.instruments.remoteserver.DVTSecureSocketProxy","level":"debug","msg":"Service started on device","time":"2023-01-26T10:59:23+01:00"}\n{"channel_id":"com.apple.instruments.server.services.deviceinfo","level":"debug","msg":"Requesting channel","time":"2023-01-26T10:59:23+01:00"}\n{"level":"debug","msg":"DTX Connection with EOF","time":"2023-01-26T10:59:23+01:00"}\n{"level":"debug","msg":"i0.0 c0 t:Ack mlen:0 aux_len0 paylen0","time":"2023-01-26T10:59:28+01:00"}\n{"channel_id":"com.apple.instruments.server.services.deviceinfo","error":"Timed out waiting for response for message:5 channel:0","level":"error","msg":"failed requesting channel","time":"2023-01-26T10:59:28+01:00"}\n{"channel_id":"com.apple.instruments.server.services.deviceinfo","level":"debug","msg":"Channel open","time":"2023-01-26T10:59:28+01:00"}\n{"channel_id":"com.apple.instruments.server.services.deviceinfo","error":"Timed out waiting for response for message:1 channel:1","level":"info","methodselector":"runningProcesses","msg":"failed starting invoking method","time":"2023-01-26T10:59:33+01:00"}\npanic: runtime error: index out of range [0] with length 0\n\ngoroutine 1 [running]:\ngithub.com/danielpaulus/go-ios/ios/instruments.DeviceInfoService.ProcessList({0xc0002ca1e0, 0xc000059bc0})\n\tD:/a/go-ios/go-ios/ios/instruments/instruments_deviceinfo.go:26 +0x137\nmain.Main()\n\tD:/a/go-ios/go-ios/main.go:586 +0x3159\nmain.main()\n\tD:/a/go-ios/go-ios/main.go:52 +0x17\n'

shamanec commented 1 year ago

Are you running the launch and kill commands synchronously? Do you wait for the launch to return successfully before running kill? Have you tried adding a small sleep duration between each command execution? I can't really tell what is wrong but maybe the usbmuxd connection dies for some reason. I could not reproduce this in 100 tries