Add experimental Session Replay capturing on Mac#1425
Conversation
|
JoshuaMoelans
left a comment
There was a problem hiding this comment.
lgtm, just a small fix on some bot-formatting + one follow-up question:
Q: could we have some tests for the session replay behaviour? I can imagine it's hard to capture actual session replays in CI, but maybe we can unit test certain parts of the flow?
…der.cpp Co-authored-by: JoshuaMoelans <60878493+JoshuaMoelans@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 536aa97. Configure here.
Testing replay capturing in CI doesn't seem particularly realistic (at least with GitHub-hosted runners) since it requires actual rendering to occur (non-null RHI) and the codec behavior is hardware-bound (NVENC requires an Nvidia GPU while VT runs only on macOS where we don't currently run checks at all). The only component that's unit-testable in isolation is |
This PR adds macOS-specific details to the Session Replay docs for Unreal SDK. Related items: - getsentry/sentry-unreal#1425

This PR extends the opt-in Session Replay feature support to macOS allowing the SDK to continuously record the last several seconds of gameplay into a MP4 file and attach it to crash reports.
Example crash event with Session Replay attached (Mac).
Key Changes
FMacSentrySubsystemnow spawns the recorder in both backend modes (Cocoa and Native). The resulting.mp4is attached viaonLastRunStatusDeterminedwhen using the Cocoa backend and via the in-processOnCrashhook when using the Native backend.FSentryBackBufferCapturenow parameterizes its texture acquisition helpers over(format, flags, initial state), allowing the sameFCachedTexture/FCachedTexturePoolinfrastructure to be shared across platforms.On macOS, the capture pipeline introduces an intermediate texture between the format-conversion draw pass and the CPU-readable pool slot, as Metal does not allow
RenderTargetableandCPUReadbackflags on the same texture.Engine Dependencies
In addition to
AVCodecsCore, Mac builds require the experimentalVTCodecsplugin (Mac-only, ships with UE 5.2+). Both must be enabled in the project forUSE_SENTRY_SESSION_REPLAYto be defined (guards session replay code).Other Considerations
TexCreate_CPUReadbackon the texture it receives, while Metal RHI does not allowTexCreate_CPUReadbackandTexCreate_RenderTargetableto be used on the same texture. As a result, the macOS path performs one additional GPU copy from a singletonBGRA8render-target intermediate into the CPU-readable texture from the pool.Encoder->SendFrameexpects timestamps in microseconds on VT (whereas NVENC treats them as opaque values), andPacket.Timestampis returned asmach_absolute_timehost-clock ticks (whereas NVENC echoes the original value unchanged). The encoder thread now performs platform-specific timestamp conversion, scalingSendFrametimestamps to microseconds on macOS and converting packet timestamps viaFPlatformTime::ToMilliseconds64.Documentation
Related items