dryark / stf_ios_support

Central repo to connect and document components/repos needed for IOS stf support
Other
153 stars 65 forks source link

Simultaneous Multiple Device Support #8

Open nanoscopic opened 4 years ago

nanoscopic commented 4 years ago

Simultaneous support on a single provider machine works currently with the exception of video. It appears currently that AVFoundation / ffmpeg reading video from multiple devices at once on the same machine doesn't work.

For the current time, video can be set to 'false' in config.json to skip video if video is not needed.

Bull3time commented 4 years ago

Are there any plans here?

I mistakenly assumed you could have multiple video feeds if one device was vnc and another wasnt, but the video feed of the first one plugged in dies.

Im also attempting to use a vm to host another provider, so mac host is a provider for one device to a docker-compose stf instance and a vm with a phones usb passed in also to that stf docker instance on the mac host. Make dist/offline doesnt account for all the go requirements, and thus far i havent been successful getting it to connect to the zmq/it could be a compile issue from the zmg.go errors. Granted this could be its own issue i should create but this is all in the vein of hosting multiple devices from the one stf provider ‘machine’.

nanoscopic commented 4 years ago

With the latest update to how video streaming functions, multiple simultaneous devices should now function. This is theoretical at this time though; I haven't actually tested doing so yet. Whether it works properly will be limited by whether your device is capable of simultaneously decoding multiple video streams using videotoolbox.

Will update more once it has been tested out and ensured that it functions as expected.

nanoscopic commented 4 years ago

This is currently blocked by this issue: https://github.com/danielpaulus/quicktime_video_hack/issues/44

nanoscopic commented 4 years ago

The latest changes to ios_video_pull address the blocking issue. So far I have tested simultaneous streaming of video using two instances each of ios_video_pull and h264_to_jpeg. Testing of full STF connectivity of two devices simultaneously is not yet finished but coming.

chriiis78 commented 4 years ago

Hi @nanoscopic I want to report you this issue: https://github.com/tmobile/stf_ios_support/blob/master/wda_wrapper/wda_wrapper.go#L118

The port should always be 8100, contrary to the wdaproxy port. Now, I've tested 2 iPhones within the localhost:8100 and localhost:8101.

nanoscopic commented 4 years ago

My understand of how wdaproxy works:

  1. Start WDA itself on the local system / phone. WDA listens by default on localhost:8100.
  2. Find a "free port" ; and use iproxy to forward that "free port" to 8100
  3. Forward *:8100 to the free port using tcpproxy

In my initial testing if I let WDA run on 8100 for both devices ( step 1 ) it failed / conflicted. I had to move the port of the second device. What is confusing to me is where WDA is actually listening on port 8100; because it is using iproxy that seems to imply to me port 8100 is actually on the device; but that doesn't make sense if localhost:8100 works; as I don't think WDA itself runs iproxy.

Suffice it to say, the code as is works with two devices when video is turned off. I believe the latest code will work with video enabled also but I haven't tested that fully yet as I've been saying.

What change are you proposing and have you tested it? There is certainly no requirement that WDA ever run on port 8100 specifically in any of the cases. All the ports are configurable.

chriiis78 commented 4 years ago

I specified the line 118, the -q argument when calling wdaproxy.

For my understanding, the -q argument is the port of WebDriverAgent, eg: http://192.168.1.10:8100/

When the first device is connected, the wdaproxy port is -p 8100 and -q 8100 But when the second device connects, the wdaproxy have -p 8101 and -q 8101. With this configuration when accessing localhost:8101 the home page of wdaproxy shows, but the localhost:8101/status response is Bad Gateway 502 because it can’t access to WebDriverAgent.

That’s why i recommend to always use -q 8100. Also -p have to be different for each device.

chriiis78 commented 4 years ago

@nanoscopic if you are interested, i made a fork of your ios_video_stream and use the idevicescreenshot instead of QVH. I've tested with 2 devices.

I have some issues when connecting the second device, often it shows:

INFO[0032] Device object created                         dev_ios_port=9241 dev_name= dev_uuid="***68c3" type=devd_create vid_port=8001 vnc_port=5902 wda_port=8101
INFO[0032] Device connected                              dev_name= dev_uuid="***68c3" type=dev_connect
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
github.com/nanoscopic/ujsonin/mod.Parse(0xc0003a6a00, 0x0, 0x200, 0x200, 0x0, 0x0, 0xc00019e688)
    /Users/chris/go/pkg/mod/github.com/nanoscopic/ujsonin@v1.6.0/mod/ujsonin.go:175 +0x1734
main.ivp_enable(0xc00026c065, 0x28, 0x0, 0x0)
    /Users/chris/Documents/tmp/chris/stf_ios_support/coordinator/coordinator.go:665 +0x12e
main.event_loop(0xc000180000, 0xc0000b64d0, 0xf, 0xc00008e1e0, 0xc0000b4540, 0xc000028ec9, 0x3, 0xc00008e180, 0xc00009b2f0, 0xc0000b62c8, ...)
    /Users/chris/Documents/tmp/chris/stf_ios_support/coordinator/coordinator.go:514 +0x2391
main.main()
    /Users/chris/Documents/tmp/chris/stf_ios_support/coordinator/coordinator.go:318 +0x111c

Also, sometimes, the process stuck here:

INFO[0005] ideviceinfo call                              ops="[-u ***ef22 -k ProductVersion]" type=ilib_getinfo_call

I don't know if all of those errors is because it's running on a VM?