Skip to content

Fix the 5-second delay before tvOS screenshots and video streams - #987

Open
DylanVann wants to merge 1 commit into
meta:mainfrom
DylanVann:fix/tvos-no-integrated-display
Open

DylanVann wants to merge 1 commit into
meta:mainfrom
DylanVann:fix/tvos-no-integrated-display

Conversation

@DylanVann

Copy link
Copy Markdown

The description and changes were generated using AI, and reviewed by me.

Every screenshot and video stream of an Apple TV simulator waits 5 s before capturing anything. On a new Apple TV 4K (3rd generation) simulator with tvOS 27.0, idb screenshot takes about 5.5 s each time with v1.7.7, against about 0.6 s on an iPhone 17 Pro. The companion's log says why:

Capturing the main screen, as the active display could not be captured: noActiveIntegratedDisplay

An Apple TV's only display is its TV output, which its display report lists as external (the shape in SimulatorDisplayReadTests.reportWithOnlyAnExternalDisplayHasNoActiveIntegratedDisplay). SimulatorDisplayResolution finds no active integrated display, and resolveDisplay() waits that out for transitionSettling.timeout (5 s), as it should during a hinge change, before throwing; SimulatorScreenshotCommands.capture then captures the main screen. On an Apple TV no integrated display is coming, so every screenshot waits the full 5 s, and so does every video stream's first frame (5.2 s). (Since 61a0808 and the commits after it, a tvOS screenshot falls back to the main screen instead of failing; that fallback comes once the wait has timed out.)

Change: a report that lists displays, none of them integrated, resolves to a new fallback, noIntegratedDisplay, which isn't waited out, so the capture goes to the main screen straight away. An empty report, and reports with integrated displays, resolve as before: a foldable's cover and inner displays are both integrated, so a hinge change still passes through noActiveIntegratedDisplay or ambiguousActiveDisplays and is still waited out.

Tests:

  • DisplayCommandsTests.aRuntimeWithOnlyATVOutputFallsBackWithoutWaiting: a report with only a TV output resolves to .fallback(.noIntegratedDisplay) after one read.
  • SimulatorDisplayReadTests.reportWithOnlyAnExternalDisplayHasNoIntegratedDisplay (renamed): tvOS's report shape with backlight off now resolves to .noIntegratedDisplay; with unknown, still to .legacyIntegratedDisplays(count: 0).
  • ./build.sh test FBSimulatorControl: all 431 tests pass.

To reproduce:

udid=$(xcrun simctl create tv com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-3rd-generation-4K com.apple.CoreSimulator.SimRuntime.tvOS-27-0)
xcrun simctl boot "$udid"
idb_companion --udid "$udid" --grpc-port 10882 &
idb connect localhost 10882
time idb screenshot --udid "$udid" tv.png
New simulator idb screenshot, 3 runs
Apple TV 4K (3rd generation), v1.7.7 5.64 s, 5.49 s, 5.45 s
Apple TV 4K (3rd generation), this change 0.77 s, 0.38 s, 0.38 s
iPhone 17 Pro, v1.7.7 3.37 s (first), 0.64 s, 0.56 s

We found this running react-native-fast-image's regression tests on an Apple TV simulator, with screenshots and video from the companion's gRPC API: the tvOS cases took about 18 minutes, and about 3 with this change.

An Apple TV simulator's only display is its TV output, an external
display, so resolving the display a screenshot or video stream targets
found no active integrated display. That is waited out, as it passes
during a hinge change, so every screenshot and every video stream of an
Apple TV waited the full 5 s before capturing the main screen anyway.

A report that lists displays, none of them integrated, now falls back
to the main screen straight away (noIntegratedDisplay).
@meta-cla meta-cla Bot added the CLA Signed label Oct 22, 2026
@DylanVann DylanVann changed the title Don't wait for an integrated display on a simulator without one Fix the 5-second delay before tvOS screenshots and video streams Oct 22, 2026
DylanVann added a commit to DylanVann/react-native-fast-image that referenced this pull request Oct 22, 2026
The patched idb companion's README links meta/idb#987: once it's in a release, the workflow can download that release again and the folder can go.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant