Repository navigation
fix(screenshots): Read back screenshots in their own format - #2917
Merged
Merged
Conversation
bitsandfoxes
marked this pull request as ready for review
October 29, 2026 15:56
bitsandfoxes
requested review from
a team,
jpnurmi,
limbonaut and
tustanivsky
October 29, 2026 16:01
jpnurmi
approved these changes
Oct 29, 2026
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.CaptureAsyncaskedAsyncGPUReadbackto convert the screenshot toRGBA32. 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
EncodeArrayToJPGencodes from that samegraphicsFormat. There's no GPU conversion and no hardcoded format, so it doesn't depend on the platform or graphics API.EncodeArrayToJPGaccepts every non-integer colorGraphicsFormat(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 withSetBeforeSendScreenshotor 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_ReadsBackScreenshotfails with the error on Metal before this change and passes after.#skip-changelog
🤖 Generated with Claude Code