Record iOS real device with appium

Hi ,

Has someone managed to record iOS real device execution through appium ?

I did manage to start the recording and to stop it , but when it being converted from base64 format to file with mp4 format , the file cannot be opened (getting corrupted error) - this does work for Android tough.

thanks.


No I see that the problem is with ffmpeg package

[ffmpeg] [mjpeg @ 0x7f9583000600] Found EOI before any SOF, ignoring
[ffmpeg] [mjpeg @ 0x7f9583000600] bits 103 is invalid
[ffmpeg] [mjpeg @ 0x7f9581802e00] decoding for stream 0 failed
[ffmpeg]
[ffmpeg] [mjpeg @ 0x7f9581802e00] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown), lossless): unspecified size
[ffmpeg] Consider increasing the value for the 'analyzeduration' and 'probesize' options
[ffmpeg] Input #0, mjpeg, from 'http://localhost:9100':
[ffmpeg]   Duration: N/A, bitrate: N/A
[ffmpeg]     Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), lossless, 10 tbr, 1200k tbn, 10 tbc
[ffmpeg] Stream mapping:
[ffmpeg]   Stream #0:0 -> #0:0 (mjpeg (native) -> mjpeg (native))
[ffmpeg] Press [q] to stop, [?] for help
[ffmpeg] Cannot determine format of input stream 0:0 after EOF
[ffmpeg] Error marking filters as finished
[ffmpeg] Exiting normally, received signal 2.

Any one have a solution for it ?

Thanks

Make sure the WDA binary is up to date and is not cached on the device

And how do I do that?

Uninstall WDA from your device and then reinstall by the standard Appium setup process would be my guess

The installation usually being made when the test is executed, each time new instance, or I’m wrong?

Im not 100% sure about that and I wouldnt be surprised if it depends on your configuration… In my experience, Appium looks for WDA already installed on the device and if it is not there, it gets installed. I think this is what mykola was referring to as a “cached WDA”… you might have an old version of WDA on your device and a new one is not being installed because Appium is finding a valid install already and moving on.

@Smitty ,
Just to make it clear , WDA is the non iconed “application” which being installed by Appium once I launch the test ?

If the answer is yes , then each execution it being removed and installed from scratch , in anyway , I’ve also tried to remove it manually and then to relaunch the test , the outcome is the same.

[HTTP] → POST /wd/hub/session/b9f3676b-3fbf-4061-85fc-b1feb1f61e10/appium/start_recording_screen
[HTTP] {}
[debug] [W3C] Calling AppiumDriver.startRecordingScreen() with args: [null,“b9f3676b-3fbf-4061-85fc-b1feb1f61e10”]
[debug] [XCUITest] Executing command ‘startRecordingScreen’
[XCUITest] Checking if there is/was a previous screen recording. Set ‘forceRestart’ option to ‘true’ if you’d like to skip this step.
[XCUITest] Screen recording is not running. There is nothing to stop.
[debug] [XCUITest] Starting iproxy to forward traffic from local port 9100 to device port 9100 over USB for the device c6b7cd4065b11af024f45d249d91dd35d735d916
[ffmpeg] ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
[ffmpeg] built with Apple LLVM version 9.1.0 (clang-902.0.39.2)
[ffmpeg] configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
[ffmpeg]
[ffmpeg] libavutil 56. 14.100 / 56. 14.100
[ffmpeg] libavcodec 58. 18.100 / 58. 18.100
[ffmpeg] libavformat 58. 12.100 / 58. 12.100
[ffmpeg] libavdevice 58. 3.100 / 58. 3.100
[ffmpeg] libavfilter 7. 16.100 / 7. 16.100
[ffmpeg] libavresample 4. 0. 0 / 4. 0. 0
[ffmpeg] libswscale 5. 1.100 / 5. 1.100
[ffmpeg] libswresample 3. 1.100 / 3. 1.100
[ffmpeg] libpostproc 55. 1.100 / 55. 1.100
[ffmpeg]
[ffmpeg] [tcp @ 0x7feb24000300] Connection to tcp://localhost:9100 failed (Connection refused), trying next address
[ffmpeg]
[XCUITest] Starting screen capture on the device ‘c6b7cd4065b11af024f45d249d91dd35d735d916’ with command: ‘ffmpeg -f mjpeg -r 10 -i http://localhost:9100 -vcodec mjpeg -y /var/folders/c0/yc264yk52_jb580kgkdnmjkxh3sh8r/T/2018729-87083-1hhjapy.oc1r/appium_26c4d6.mp4’. Will timeout in 180ms
[debug] [W3C] Responding to client with driver.startRecordingScreen() result: “”
[HTTP] ← POST /wd/hub/session/b9f3676b-3fbf-4061-85fc-b1feb1f61e10/appium/start_recording_screen 200 10023 ms - 12
[HTTP]
[ffmpeg] [mjpeg @ 0x7feb25800600] bits 155 is invalid
[ffmpeg] [mjpeg @ 0x7feb23802e00] decoding for stream 0 failed
[ffmpeg]
[ffmpeg] [mjpeg @ 0x7feb23802e00] Could not find codec parameters for stream 0 (Video: mjpeg, none(bt470bg/unknown/unknown), lossless): unspecified size
[ffmpeg] Consider increasing the value for the ‘analyzeduration’ and ‘probesize’ options
[ffmpeg]
[ffmpeg] Input #0, mjpeg, from ‘http://localhost:9100’:
[ffmpeg] Duration: N/A, bitrate: N/A
[ffmpeg] Stream #0:0: Video: mjpeg, none(bt470bg/unknown/unknown), lossless
[ffmpeg] , 10 tbr, 1200k tbn, 10 tbc
[ffmpeg]
[ffmpeg] Stream mapping:
[ffmpeg] Stream #0:0#0:0 (mjpeg (native) → mjpeg (native))
[ffmpeg] Press [q] to stop, [?] for help
[ffmpeg] Cannot determine format of input stream 0:0 after EOF
[ffmpeg] Error marking filters as finished
[ffmpeg]
[ffmpeg] Exiting normally, received signal 2.
[ffmpeg]
[XCUITest] Shutting down iproxy process (pid 91276)
[debug] [XCUITest] iproxy exited with code ‘null’
[debug] [XCUITest] Connection to WDA timed out
[debug] [iProxy] recv failed: Operation not permitted
[HTTP] → POST /wd/hub/session/b9f3676b-3fbf-4061-85fc-b1feb1f61e10/appium/stop_recording_screen
[HTTP] {}
[debug] [W3C] Calling AppiumDriver.stopRecordingScreen() with args: [null,“b9f3676b-3fbf-4061-85fc-b1feb1f61e10”]
[debug] [XCUITest] Executing command ‘stopRecordingScreen’
[debug] [XCUITest] The size of the file is 0 B
[debug] [W3C] Responding to client with driver.stopRecordingScreen() result: “”
[HTTP] ← POST /wd/hub/session/b9f3676b-3fbf-4061-85fc-b1feb1f61e10/appium/stop_recording_screen 200 7 ms - 12

Seems like the problem is with ffmpeg recorder

Did you guys have a success with recording iPhone device ?

Thanks

You are correct about which app it is… Well, like I said, it probably depends on your configuration. I just confirmed that my WDA stays cached on my device between tests but that could be because I installed it manually with my own dev license… Anyways… Ive never tried to record video during a test so we are moving out of my element a bit… That said… I can try to make an educated guess:

The line:

Connection to tcp://localhost:9100 failed (Connection refused)

In your logs stands out to me a bit… It looks like XCUITest is getting an HTTP connection through that port but an attempt using TCP by ffmpeg gets actively blocked. Im sorry I dont have an answer handy for this since I have never looked into it but, if it were me, my first google search would be “WDA allow tcp connections” and also “ffmpeg connect to WDA”… etc… Hopefully someone else with some experience in this can read this and jump in

Good Luck!

Thanks for the reply!

Already tried all possible search permutations in Google, but nothing informative enough…

Hope that anyone else has more success with the recording than I had…