Skip to content

fix(screenshots): Read back screenshots in their own format - #2917

Merged
bitsandfoxes merged 1 commit into
mainfrom
fix/ios-screenshot-readback
Oct 29, 2026
Merged

bitsandfoxes merged 1 commit into
mainfrom
fix/ios-screenshot-readback

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #2835, whose async screenshot path isn't released yet.

On Metal (iOS and macOS, linear color space) every event was followed by an SDK error event, 'B8G8R8A8_SRGB' doesn't support ReadPixels usage on this platform. Async GPU readback failed., and on iOS devices the screenshot came out empty. CaptureAsync asked AsyncGPUReadback to convert the screenshot to RGBA32. The temporary render texture has the backbuffer's format, which is BGRA sRGB on Metal, and Unity can't convert from it there. Unity logs the error, and the SDK captures that log as an event.

The readback now uses the render texture's own format, and EncodeArrayToJPG encodes from that same graphicsFormat. There's no GPU conversion and no hardcoded format, so it doesn't depend on the platform or graphics API. EncodeArrayToJPG accepts every non-integer color GraphicsFormat (checked in the Editor; the encode runs on the CPU), and sRGB targets keep their colors. On D3D, GLES and Vulkan the old readback was an RGBA-to-RGBA no-op, so those read the same bytes as before. The synchronous path, used with SetBeforeSendScreenshot or without async readback support, is unchanged.

Verified on an iPhone (iOS 27): a C# event arrived with a 126 KB screenshot of the actual screen, and no error event followed it. CaptureAsync_ReadsBackScreenshot fails with the error on Metal before this change and passes after.

#skip-changelog

🤖 Generated with Claude Code

@bitsandfoxes
bitsandfoxes marked this pull request as ready for review October 29, 2026 15:56
@bitsandfoxes
bitsandfoxes requested review from a team, jpnurmi, limbonaut and tustanivsky October 29, 2026 16:01
@bitsandfoxes
bitsandfoxes merged commit b9dfa35 into main Oct 29, 2026
134 of 135 checks passed
@bitsandfoxes
bitsandfoxes deleted the fix/ios-screenshot-readback branch October 29, 2026 16:59
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.

2 participants