Skip to content

Resolve iOS sandbox path before uploading session replay envelope - #1518

Merged
tustanivsky merged 4 commits into
mainfrom
fix/ios-replay-sandbox-path
Aug 5, 2026
Merged

tustanivsky merged 4 commits into
mainfrom
fix/ios-replay-sandbox-path

Conversation

@tustanivsky

@tustanivsky tustanivsky commented Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

On iOS, session replay video captured for a previous run's crash wasn't uploaded to Sentry due to its invalid sandbox path (likely a regression from #1468). On the launch following a crash the SDK logged:

LogSentrySdk: Warning: Session replay: failed to read video file at ../../../<Project>/Saved/SentryReplays/replay-<id>.mp4

The recorder writes the replay .mp4 through IFileManager (CreateFileWriter → Move). On iOS, IFileManager transparently remaps the UE virtual Saved/ path into the app sandbox (Documents/Caches), so the file physically lands there.

When building the crash envelope, FAppleSentryReplayEnvelope::CaptureForCrashEvent reads the video with [NSData dataWithContentsOfFile:] which is a native API that does not apply that sandbox remapping. It received the unmapped UE path, so the read failed and the replay was dropped. The metadata sidecar read succeeded because it goes through FFileHelper/IFileManager, which does the remapping.

Suggested Fix

Resolve the real on-disk path with IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead() before handing it to NSData. On iOS this runs the same sandbox mapping the writer used (and falls back to the write-mapped location), and on other Apple platforms it's a no-op.

Testing

Verified on device (iPhone, iOS): reproduced the crash → relaunch cycle. Before the change the video read failed with the warning above; after the change the replay video is read and uploaded.

Example replay captured on iOS.

@tustanivsky
tustanivsky force-pushed the fix/ios-replay-sandbox-path branch from c0bdf46 to dac80cd Compare August 5, 2026 11:38
@tustanivsky tustanivsky changed the title fix(replay): Resolve iOS sandbox path before native video read Resolve iOS sandbox path before native video read Aug 5, 2026
@tustanivsky tustanivsky changed the title Resolve iOS sandbox path before native video read Resolve iOS sandbox path before uploading session replay envelope Aug 5, 2026
On iOS the session replay recorder writes the video through IFileManager,
which remaps the UE virtual Saved/ path into the app sandbox. When capturing
the replay for a previous run's crash, the video was read via NSData using
the unmapped path, so the read failed and the replay was never uploaded.

Resolve the real on-disk path with ConvertToAbsolutePathForExternalAppForRead
before handing it to NSData, and include the resolved path in the failure log.
@tustanivsky
tustanivsky force-pushed the fix/ios-replay-sandbox-path branch from 84d6f6c to 5a9ec7d Compare August 5, 2026 12:09
@tustanivsky
tustanivsky merged commit 416c03f into main Aug 5, 2026
104 of 105 checks passed
@tustanivsky
tustanivsky deleted the fix/ios-replay-sandbox-path branch August 5, 2026 13:14
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.

3 participants