Skip to content

fix(ios): allocate unique MJPEG ports for recording sessions - #2066

Merged
saikrishna321 merged 1 commit into
AppiumTestDistribution:mainfrom
aglbv:fix/ios-recording-mjpeg-ports
Nov 23, 2026
Merged

saikrishna321 merged 1 commit into
AppiumTestDistribution:mainfrom
aglbv:fix/ios-recording-mjpeg-ports

Conversation

@aglbv

@aglbv aglbv commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Concurrent iOS session creation can interrupt a recording and reconnect it to another device's MJPEG stream. The resulting MP4 can still decode successfully and have approximately the expected duration while showing the wrong device.

The live-streaming removal in #2056 also removed iOS MJPEG port allocation. Screen recording still consumes MJPEG, so sessions without an assigned port fall back to 9100. iOSCapabilities also removes a client-supplied appium:mjpegServerPort from alwaysMatch.

This change allocates a separate MJPEG port for each iOS session using the existing getFreePort(options.portRange) helper, passes it to XCUITest, and stores it on the allocated device so the existing cleanup paths can release it. Six regression tests cover real devices and simulators, shared client-supplied ports, concurrent allocation, persistence, and the configured port range.

Reproduction and comparison

  1. On one host, create two real-device iOS sessions concurrently with df:options: {recordVideo: true}. Do not supply mjpegServerPort or df:name.
  2. Open Settings on one device and Clock on the other. Keep both sessions active for at least 30 seconds.
  3. Compare direct screenshots with the recorded video frames; also inspect the FFmpeg input ports and reconnect messages.

Compared the same baseline and baseline plus this five-line production change on iOS 17.3.1 and 26.1, with two simultaneous-start rounds per variant:

Observation Baseline With this change
FFmpeg input ports Both use 9100 Different port per session
Premature MJPEG stream termination / reconnect Present in both rounds None in either round
Recorded device Clock session records the other device's Settings screen in both rounds Sampled frames match each device in both rounds

An additional control with sequential session creation and overlapping recordings passed on both variants. All 12 MP4 files across the controls and simultaneous-start tests passed full decoding; decoding alone did not detect the wrong-device recordings.

Both arms used the same XCUITest 12.15.0 installation, including an existing local recording-timestamp adjustment. Driver source and compiled-file hashes were unchanged throughout the comparison. This test isolates the Device Farm change; it does not establish a general fix for shortened video duration.

Validation

  • Plugin unit suite on Node 20: 132 passing, 4 pending, including the six new regression cases.
  • TypeScript compilation and webpack bundling passed for both comparison builds.
  • Prettier check for both changed files and git diff --check passed.
  • Real-device A/B comparison as described above. No live simulator or GO_IOS validation was performed.

The existing second port-forwarding attempt in the plugin can still log a caught port-in-use warning after XCUITest has forwarded the allocated port; no recording failure resulted from it in this comparison.

Related background: appium/appium#12219 documents the need for separate MJPEG ports during parallel recording.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Some pipeline(s) encountered errors during trigger evaluation.

@saikrishna321
saikrishna321 merged commit 89d0fda into AppiumTestDistribution:main Nov 23, 2026
4 checks passed
saikrishna321 pushed a commit that referenced this pull request Nov 23, 2026
## [12.0.3](v12.0.2...v12.0.3) (2026-11-23)

### Bug Fixes

* allocate unique MJPEG ports for iOS sessions ([#2066](#2066)) ([89d0fda](89d0fda))
* count queue time against the device availability timeout ([#2067](#2067)) ([5943ed5](5943ed5)), closes [#2064](#2064)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants