Help! Screen Capture Function takes 5 seconds for 1 image!

Our testing taking screen capture every second to do some analysis but found that it takes about 5 seconds to get 1 image.
Our architecture is that the testing python program (which do only screen capture every second) and appium server run in the same laptop (surface pro 4 if it matters)
We tried to (1) reduce the reosolution (2) using USB3.0 cable + type c cable + usb3.0 (in surface pro) with Samsung Note 8, (3) reduce log level, but still cannot improve the speed. Can any tell me what the bottleneck actually is and how we improve the speed (to within a second).

testing spec:
appium version is 1.6.3
surface pro 4
samsung note 8
usb 3.0 cable

It is a major bottleneck for us now. we are really appreciated for your help in advance.

can you attach server logs with timestamps?

Try to reduce device resolution if possible.

Here you go. The format is a little different the lively log.
appium-server-logs.txt (88.0 KB)

Here is the message in the screen when I run the program:
GET /wd/hub/session/b9b0f5b9-068b-4045-a6b9-8831fadd3e5d/screenshot 200 4486 ms - 3014772
GET /wd/hub/session/b9b0f5b9-068b-4045-a6b9-8831fadd3e5d/screenshot 200 5083 ms - 3003356
GET /wd/hub/session/b9b0f5b9-068b-4045-a6b9-8831fadd3e5d/screenshot 200 4652 ms - 2992196
…
the time needed are ranged from 4 - 5 seconds.

Thank you Aleksei and Mykola.

Yes, we did try to reduce the screen resolution using the following method:

When we use the old phone with lower resolution, we find little bit improvement. The pending problems are:

(1) to be honest, after we reduce the resolution to half using the method above (the desktop apps layout is completely distorted already), the photos we get are still in the same resolutions. we may do the wrong setting (please advice if so) but the reason can be that the app is run with video streaming so the resolutions are not reduced.
(1) Because of (1), we use old phone to test (the cable is reduce to USB2.0). The size of the photo reduce from 2.xxMB to ~1MB, becuase of the screen size (and resolution), the speed improve about a second or 2 to around 3 second but still not significant

My guess was that with USB3.0, it should be few times faster but the result is so weird to me. Also, I suspect that there is some setting bottleneck that yet to clean up. I suppose a screen capture take less than a second.

Switch to UiAutomator2
UIA1 is obsolete and unsupported for Android 6+

Mykola. Thank you very much for your help. the advice has been very helpful. I tested and seems to reduce the time to needed by half to 2 seconds. May I know is it the limited already ? Is there any chance I can reduce it to within a minute?

I don’t think this can be reduced even more, since UIA2 retrieves the actual screenshot bitmap directly from the system framework. You could try switching to Espresso backend and check how it performs there, however that driver is in early beta stage.

Thank you. May I learn what the key bottleneck is here? E.g. if I ensure the phone type c port is also USB 3.0 (I suspect samsung note 8 actually still using 2.0), will it improve sthe performance ? Or will it work if I add ram or change a more powerful CPU? (Change to powerful desktop instead of surface pro)

This all requires too much effort and does not promise any noticeable improvements. If you need the process to be really fast then try to capture a video in higher quality instead. Then you could split the video to separate frames/screenshots it you want. https://github.com/appium/java-client/blob/master/src/test/java/io/appium/java_client/android/AndroidScreenRecordTest.java

1 Like

Thank you. You are very helpful.

We will do some further testing before we make decision.

Thank you once again.