Fast screenshot capturing for Android

Current screenshot capturing for Android in Native View when calling driver.getScreenshotAs(…) works in such way that Appium Server is executing these adb command:

info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 5200f3114120c2d5 shell "/system/bin/rm /data/local/tmp/screenshot.png; /system/bin/screencap -p /data/local/tmp/screenshot.png "
info: [debug] executing cmd: C:\android-sdk\platform-tools\adb.exe -s 5200f3114120c2d5 pull /data/local/tmp/screenshot.png “C:\SecretTemporaryLocation\appium11664-11492-1xftly0.png”

This is not so good, as pulling screenshot from device is quite time consuming operation.
On big resolution devices it can take 10+ seconds.
If Appium server would create unique name for each screenshot then we could collect screenshot in background (in separate thread) and it would a huge increase in test execution time
For games testing it is must have feature as currently we can only guess about maximal time which is needed for screenshot capturing and during that time we can miss next test step as there were gameplay changes which were not captured as driver was waiting for screenshot not for these expected UI changes.

What do you think about such a feature?

I made a POC how we could run screenshoting in separate thread, so then only problem is that adb command for screenshot doesn’t have unique name, otherwise this would work
http://paste.ofcode.org/pFiGirPPQHbfN4pV6iPnye

How much improvement did you get from this???

Taking screenshot with big resolution device can take up to 8 - 10 seconds, if unique screenshot name would be provided then before next test step we only need to wait for screenshot command to be received on adb, which would be 0.5 second max and is not dependent on screenshot size. So gain could be 20x or even more.