Java-client: Android Screen-recording not working as expected if the duration of run is lesser than the default or set timelimit

Created on 24 Jan 2019  路  9Comments  路  Source: appium/java-client

Description

Android Screenrecording generates zero duration video file; if the test duration is lesser than default recording time limit or set time limit.

Environment

  • java client - 6.1.0 & 7.0.0
  • Appium server version: 1.10.0
  • Desktop OS/version used to run Appium if necessary: Executed in MAC 10.13.6
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 11.5.0
  • Mobile platform/version under test: Tested against Android 8.1, 9.0
  • Real device or emulator/simulator: Same behaviour observed in both

Details

Scenario 1:
Test duration: 60 seconds
Use driver.startRecordingScreen (without any options; default time limit 180 seconds)
Actual result: It generates zero duration mp4 file

Scenario 2:
Test Duration: 60 seconds
Use driver.startRecordingScreen (with time limit option say 150 or 200 seconds)
Actual result: It generates zero duration mp4 file

Scenario 3:
Test Duration: 200 seconds
Use driver.startRecordingScreen (with time limit option say 200 seconds)
When test fails in between say at 70th second or so.
Actual result: It generates zero duration mp4 file

Ecxeption stacktraces

No exceptions or error thrown

Code

driver.startRecordingScreen (without any options)
driver..startRecordingScreen(
new AndroidStartScreenRecordingOptions().withTimeLimit(Duration.ofSeconds(200)));

String video =driver.stopRecordingScreen();
byte[] decode = Base64.getDecoder().decode(video);
String fileName = "AndroidRego.mp4";
String finalPath = "./file-screenshots/"+fileName;
FileUtils.writeByteArrayToFile(new File(finalPath), decode);

Appium logs

Start Recording logs:
[HTTP] --> POST /wd/hub/session/fd449506-2a61-4214-ba69-c72eaea8eb5f/appium/start_recording_screen
[HTTP] {"options":{"timeLimit":200}}
[debug] [W3C (fd449506)] Calling AppiumDriver.startRecordingScreen() with args: [{"timeLimit":200},"fd449506-2a61-4214-ba69-c72eaea8eb5f"]
[debug] [ADB] Device API level: 28
[debug] [ADB] Device API level: 28
[debug] [ADB] Getting all processes with screenrecord
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ps'
[AndroidDriver] Screen recording has not been previously started by Appium. There is nothing to stop
[debug] [ADB] Getting all processes with screenrecord
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ps'
[debug] [ADB] Building screenrecord process with the command line: adb -P 5037 -s emulator-5554 shell screenrecord --time-limit 180 /sdcard/1548290374842.mp4
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ls /sdcard/1548290374842.mp4'
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ls /sdcard/1548290374842.mp4'
[debug] [W3C (fd449506)] Responding to client with driver.startRecordingScreen() result: ""
[HTTP] <-- POST /wd/hub/session/fd449506-2a61-4214-ba69-c72eaea8eb5f/appium/start_recording_screen 200 446 ms - 12
[HTTP]

Stop Recording Logs:

[HTTP] --> POST /wd/hub/session/fd449506-2a61-4214-ba69-c72eaea8eb5f/appium/stop_recording_screen
[HTTP] {}
[debug] [W3C (fd449506)] Calling AppiumDriver.stopRecordingScreen() with args: [null,"fd449506-2a61-4214-ba69-c72eaea8eb5f"]
[debug] [ADB] Device API level: 28
[debug] [ADB] Getting all processes with screenrecord
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell ps'
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 pull /sdcard/1548290374842.mp4 /var/folders/xm/cn411d9507970l9859c5snrjpjkmh4/T/2019024-25067-1h3x4w9.4777f/1548290374842.mp4'
[debug] [ADB] Running '/Users/navanepa/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell rm -rf /sdcard/1548290374842.mp4'
[debug] [AndroidDriver] The size of the resulting screen recording is 17.58 MB
[debug] [W3C (fd449506)] Responding to client with driver.stopRecordingScreen() result: "AAAAGGZ0eXBtcDQyAAAAAGlzb21tcDQyAAAMd2ZyZWUAAAAAAAAAAAAAAAAAA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ms - 24583344
[HTTP]

Most helpful comment

@KazuCocoa

@xibalba88
Was that real device?

All real devices: Android 9.0 - Pixel, Pixel 2 XL, Pixel 3 XL, Samsung S9; Android 8.1 - Nexus 5X

Have you tried with the beta version. For me it is fixed with the beta version but i have tried only on emulators. Here is the fix : https://github.com/appium/appium/issues/11276

All 9 comments

I am also facing this problem for [email protected] and [email protected] but its perfectly working fine for android in [email protected]. But in [email protected] ios video is not playable :(

@mykola-mokhnach Could you please help us in this issue? Video file recorded with [email protected]+ is not playable. I can only see one change between [email protected] and higher versions is - Recording is not getting stopped before pulling the file from emulator. In [email protected] it kills the screenrecording process before pulling the file.

I'm also facing the same problem
Appium version 1.12.1
Android version 8.1+
Works as expected on Android 8.0
_edit_
real devices

@hemantbanafal
Did _not playable_ mean you could not see it by VLC media player?
Quick Time cannot play correctly even if the format is correct, sometimes.


@xibalba88
Was that real device?
I was able to get playable video on Android 8.1 and 9.0 emulator.
The code was https://github.com/appium/ruby_lib_core/blob/fd2cbde5466a144ce8dccfc6cf330b969bcc8fd3/test/functional/android/android/mjpeg_server_test.rb , and I increased the duration over 60 sec.
Appium was current master and 1.12.1.

ah, sorry, this is not appium repo...
(mine said just this was probably not appium server issue)

@KazuCocoa

@xibalba88
Was that real device?

All real devices: Android 9.0 - Pixel, Pixel 2 XL, Pixel 3 XL, Samsung S9; Android 8.1 - Nexus 5X

@KazuCocoa

@xibalba88
Was that real device?

All real devices: Android 9.0 - Pixel, Pixel 2 XL, Pixel 3 XL, Samsung S9; Android 8.1 - Nexus 5X

Have you tried with the beta version. For me it is fixed with the beta version but i have tried only on emulators. Here is the fix : https://github.com/appium/appium/issues/11276

Appium calls https://developer.android.com/studio/command-line/adb#screenrecord to get screen video.
You can make sure the devices can get screen video correctly.
https://github.com/appium/appium-adb/blob/716d92d39fba87f79f83b404c2143365a1ee6a53/lib/tools/adb-commands.js#L1674 is the args.
If the command does not work well, the root cause is probably the devices.
(And full log is also helpful to assume the cause.)

Thanks for the advice @hemantbanafal

Retested with 1.13.0-beta.3 and the issue is resolved there!

Was this page helpful?
0 / 5 - 0 ratings