sudharsan-selvaraj / appium-dashboard-plugin

Appium plugin that provides complete test logs, video recording of test and device logs(logcat and syslogs) for easy debugging.
116 stars 28 forks source link

In Appium dashboard, recordings are not available for the execution results #81

Closed HemaPriya-18 closed 1 year ago

HemaPriya-18 commented 2 years ago

Hi Team,

In Appium dashboard, recordings are not available for the execution results. Is there any flag to enable recording?

In logs, I could find commands related to recording:

info HTTP {"options":{"videoType":"libx264","videoFps":10,"timeLimit":1800}} [debug] [AndroidUiautomator2Driver@653a (34498909)] Calling AppiumDriver.startRecordingScreen() with args: [{"videoType":"libx264","videoFps":10,"timeLimit":1800},"34498909-af63-4554-bed8-7e110442ba02"] info Appium Plugins which can handle cmd 'startRecordingScreen': appium-dashboard,device-farm info Appium Plugin device-farm is now handling cmd 'startRecordingScreen' [device-farm] Received startRecordingScreen request on driver - [object Object] info Appium Plugin appium-dashboard is now handling cmd 'startRecordingScreen' info Appium Executing default handling behavior for command 'startRecordingScreen' [debug] [ADB] Getting IDs of all 'screenrecord' processes [debug] [ADB] Running '/Users/hema/Library/Android/sdk/platform-tools/adb -P 5037 -s 14231JEC210835 shell pgrep -f \(\[\[:blank:\]\]\|\^\)screenrecord\(\[\[:blank:\]\]\|\$\)' [AndroidUiautomator2Driver@653a (34498909)] Screen recording has not been previously started by Appium. There is nothing to stop [debug] [ADB] Getting IDs of all 'screenrecord' processes [debug] [ADB] Running '/Users/hema/Library/Android/sdk/platform-tools/adb -P 5037 -s 14231JEC210835 shell pgrep -f \(\[\[:blank:\]\]\|\^\)screenrecord\(\[\[:blank:\]\]\|\$\)' [debug] [ADB] Building screenrecord process with the command line: adb -P 5037 -s 14231JEC210835 shell screenrecord --time-limit 180 /sdcard/cc3ff0b6.mp4 [debug] [ADB] Running '/Users/hema/Library/Android/sdk/platform-tools/adb -P 5037 -s 14231JEC210835 shell "[ -e '/sdcard/cc3ff0b6.mp4' ] && echo __PASS__"' [debug] [ADB] Running '/Users/hema/Library/Android/sdk/platform-tools/adb -P 5037 -s 14231JEC210835 shell "[ -e '/sdcard/cc3ff0b6.mp4' ] && echo __PASS__"' [debug] [AndroidUiautomator2Driver@653a (34498909)] Responding to client with driver.startRecordingScreen() result: "" info HTTP <-- POST /wd/hub/session/34498909-af63-4554-bed8-7e110442ba02/appium/start_recording_screen 200 543 ms - 12

Thanks

ArjunReddyD commented 2 years ago

Hello @sudharsan-selvaraj
I am facing the same issue as above, is this an existing bug??

sudharsan-selvaraj commented 2 years ago

@HemaPriya-18 @ArjunReddyD

We need additional logs to debug the actual issue. To see the additional log, locate the below file in your machine /Users/hema/.cache/appium-dashboard-plugin/appium-dashboard-plugin.log and search for Skipped parsing command for stopRecordingScreen. There will be some error logs below the above line if the video is not saved.

HemaPriya-18 commented 2 years ago

@sudharsan-selvaraj

Thanks for responding!

Please find the logs requested:

INFO : 2022-09-07T22:28:27.787Z Skipped parsing command for stopRecordingScreen INFO : 2022-09-07T22:28:29.123Z Skipped parsing command for stopRecordingScreen ERROR : 2022-09-07T22:28:29.202Z Video not saved for session 83708be0-e48c-4603-a327-9b78eb50717b. response: "" INFO : 2022-09-07T22:28:29.216Z Session terminated 83708be0-e48c-4603-a327-9b78eb50717b INFO : 2022-09-07T22:28:29.217Z New command recieved deleteSession for session 83708be0-e48c-4603-a327-9b78eb50717b INFO : 2022-09-07T22:28:29.492Z Recieved response for command deleteSession for session 83708be0-e48c-4603-a327-9b78eb50717b

sharathhatter1 commented 2 years ago

I am also facing same issue!

samagarw commented 1 year ago

I am also facing this issue .

ZGrauer commented 1 year ago

Problem

According to ADB's documentation of screenrecord the issue is with the video resolution of the recording.

Some devices might not be able to record at their native display resolution. If you encounter problems with screen recording, try using a lower screen resolution.

When Appium starts the recording with this command adb -P 5037 -s emulator-5554 shell screenrecord --time-limit 180 /sdcard//sdcard/3a2bcdbb.mp4 at the full resolution this is returned but not logged

Display is 1440x3040 @60.00fps (orientation=ROTATION_0), layerStack=0
Configuring recorder for 1440x3040 video/avc at 20.00Mbps
Content area is 1440x3040 at offset x=0 y=0
Stopping encoder and muxer
Unable to get output buffers (err=-38)
Encoder failed (err=-38)

This results in a video file being created on the device's SD card but has a 0B file size. No video is saved at the end of the test.

Video file on device while test is executing:

-rw------- 1 u0_a117  u0_a117     0 2023-03-02 10:11 3a2bcdbb.mp4

Appium logs, showing the file size as 0:

2023-03-02 10:12:10:982 - [debug] [ADB] Getting IDs of all 'screenrecord' processes
2023-03-02 10:12:10:983 - [debug] [ADB] Running 'C:\ProgramData\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell pgrep -f \(\[\[:blank:\]\]\|\^\)screenrecord\(\[\[:blank:\]\]\|\$\)'
2023-03-02 10:12:11:206 - [debug] [ADB] Running 'C:\ProgramData\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 pull /sdcard/3a2bcdbb.mp4 C:\Users\zgrauer1\AppData\Local\Temp\202322-19540-des0o1.xox2k\3a2bcdbb.mp4'
2023-03-02 10:12:11:378 - [debug] [ADB] Running 'C:\ProgramData\Android\Sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell rm -rf /sdcard/3a2bcdbb.mp4'
2023-03-02 10:12:11:551 - [debug] [AndroidUiautomator2Driver@5f2a (4d2ef65a)] The size of the resulting screen recording is 0 B

Solution

Created pull req, https://github.com/sudharsan-selvaraj/appium-dashboard-plugin/pull/120

The video size of the recording must be lowered. Again according to ADB's documentation of screenrecord the videoSize option can be used to set a lower resolution.

In the plugin's code edit $APPIUM_HOME/node_modules/appium-dashboard/lib/plugin/driver-command-executor.js starting at line 11 edit the startScreenRecording section of code to match the below. Then restart Appium and video should work.

const plugin_logger_1 = require("../loggers/plugin-logger");

Object.defineProperty(exports, "__esModule", { value: true });
exports.terminateSession = exports.takeScreenShot = exports.getLogs = exports.getLogTypes = exports.stopScreenRecording = exports.startScreenRecording = void 0;
const plugin_utils_1 = require("./utils/plugin-utils");
function startScreenRecording(driver, sessionId) {
  return __awaiter(this, void 0, void 0, function* () {

      plugin_logger_1.pluginLogger.info("Starting video recording with forced scale to '1280:720'");
      return yield (0, plugin_utils_1.makePostCall)(driver, sessionId, "/appium/start_recording_screen", {
        options: {
          videoType: "libx264",
          videoFps: 10,
          /* Force iOS video scale to fix '[ffmpeg] [libx264 @ 0x7fda5f005280] width not divisible by 2 (1125x2436)' */
          videoScale: "1280:720",
          /* Force Android size because some devices cannot record at their native resolution, resulting in error 'Unable to get output buffers (err=-38)' */
          videoSize: "1280x720",
          /* In android, adb can record only 3 mins of video. below timeLimit is used to take longer video */
          timeLimit: 1800, //in seconds (30 min)
        },
      });
  });
}

I also set videoScale for iOS devices to fix another issue with video recording on some iPhones.

ZGrauer commented 1 year ago

Verson 2.0.2 allows you to set the video resolution by adding capability dashboard:videoResolution to your test with the value widthxheight, like 1920x1080

If you don't add the capability, then the resolution defaults to 1280x720.