Improve Android Screen Record
See original GitHub issueThe problem
As an Automation Engineer using Appium, one issue that I have faced in the past is that screenrecord API does not work on devices where the manufacturer has chosen to remove such functionality out of its device shell. This is a problem that affects mostly Huawei devices as I’ve seen in a number of projects I’ve worked before.
As a workaround I first would have to disable screen recording for such devices at my framework level, later I found a way to support such devices by using Scrcpy (a solution provided by the Genymobile guys). But still, this was a very cumbersome way to handle the issue and I wish Appium could handle it in a graceful way.
One first step I took was to write a POC Node wrapper around Scrcpy binaries. After that I successfully managed to create methods at appium-adb
that can query the device shell and determine if the target device has screenrecord
binary or not, and my next step would be integrate it at the appium-android-driver
level.
However, that’s where things start to get a bit more complicated, and I thought it could be implemented the following way: before starting screen recording query adb and check whether device has screenrecord binary available, and then decide which library will use to start a screenrecord process (mostly fail proof and backwards compatible).
I’d kindly ask for the Appium team’s feedback on this whole idea. Do you think it’s a viable/desirable solution for this problem? And how could I proceed with the best implementation?
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (1 by maintainers)
Top GitHub Comments
@mykola-mokhnach thanks for your feedback, there are valid concerns in there. I don’t see this proposal as adding a fourth screenrecording method, rather as an improvement on the “classic” endpoint as adding a fallback solution for a specific case (Android devices with custom firmware).
When it comes to the scrcpy, I totally agree that there is some sort of sorcery going on there. But the codebase is actively maintained by the Genymobile team - that also uses it for its own commercial solution - so I wouldn’t be concerned about long term support of this tool.
And yes, I share the same feeling that Chinese devices are kinda of a pain to work with, but from my experience they can’t be ignored as Huawei (and Xiaomi too for that matter) have already captured a fair piece of the device market share. I can only assume there are more automation engineers out there that are dealing with the same requirement of running tests against such devices and we could try to support them too.
With all that being said, I’m willing to take over the tasks of integrating and supporting the scrcpy solution myself.
I believe we could now implement an “ultimate” screen recording API by having https://github.com/appium/io.appium.settings/pull/88 in place. The original PR uses MediaProjection SDK and could record both audio and video in HD quality starting with Android 10.