Repository navigation
feat(ios): Sentry session replay with always-masked content surfaces #11572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
771e01e
feat(ios): Sentry session replay with always-masked content surfaces
azooz2003-bit 31d458a
fix(ios): start replay with Sentry session lifecycle
azooz2003-bit e02db63
Merge origin/main into feat-ios-session-replay
azooz2003-bit 16ab74b
fix(ios): fail closed before replay masking is configured
azooz2003-bit e61208e
fix(ios): require every replay mask surface
azooz2003-bit 3701e6e
fix(ios): keep camera controls above replay host
azooz2003-bit 6c18ea1
fix(ios): validate replay masks by exact class names
azooz2003-bit bad0e12
fix(ios): preserve Sentry replay mask defaults
azooz2003-bit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
17 changes: 17 additions & 0 deletions
17
.../CmuxMobileBrowserStream/Sources/CmuxMobileBrowserStream/BrowserStreamReplayMasking.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #if canImport(UIKit) | ||
| import UIKit | ||
|
|
||
| /// Exports this package's content-rendering view classes for the app's | ||
| /// Sentry session-replay mask list without widening their access: streamed | ||
| /// browser pixels live in a plain `CALayer`, which replay's text/image | ||
| /// masking defaults cannot classify, so the hosting view must be masked by | ||
| /// class. | ||
| public struct BrowserStreamReplayMasking { | ||
| /// The browser stream view class whose layer-backed pixels must be masked. | ||
| public let maskedViewClasses: [AnyClass] | ||
|
|
||
| public init() { | ||
| self.maskedViewClasses = [BrowserStreamContentView.self] | ||
| } | ||
| } | ||
| #endif | ||
21 changes: 21 additions & 0 deletions
21
Packages/iOS/CmuxMobileCamera/Sources/CmuxMobileCamera/CameraPreviewHostView.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #if os(iOS) | ||
| @preconcurrency import AVFoundation | ||
| public import UIKit | ||
|
|
||
| /// The view that hosts the live camera preview, backed directly by an | ||
| /// `AVCaptureVideoPreviewLayer` so the layer tracks the view's bounds without | ||
| /// manual frame management. | ||
| /// | ||
| /// Public only so the app's Sentry session-replay mask list can reference the | ||
| /// class: camera frames live in the preview layer, which replay's text/image | ||
| /// masking defaults cannot classify, so this view must be masked by class. | ||
| public final class CameraPreviewHostView: UIView { | ||
| public override class var layerClass: AnyClass { AVCaptureVideoPreviewLayer.self } | ||
|
|
||
| var previewLayer: AVCaptureVideoPreviewLayer { | ||
| // Safety: `layerClass` above fixes the backing layer's type. | ||
| // swiftlint:disable:next force_cast | ||
| layer as! AVCaptureVideoPreviewLayer | ||
| } | ||
| } | ||
| #endif |
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
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
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
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
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
33 changes: 33 additions & 0 deletions
33
ios/cmuxPackage/Sources/cmuxFeature/MobileSessionReplayMasking.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| #if os(iOS) | ||
| import CmuxMobileBrowserStream | ||
| import CmuxMobileCamera | ||
| import CmuxMobileSimulatorStream | ||
| import CmuxMobileTerminal | ||
|
|
||
| /// The view classes Sentry session replay must always mask, on top of its | ||
| /// text/image/webview defaults. | ||
| /// | ||
| /// Everything here renders user content through Metal, video, or raw | ||
| /// `CALayer` pixels, which replay's class-based defaults cannot classify. | ||
| /// One central list keeps "never capture terminal, browser, simulator, or | ||
| /// camera content" a single decision instead of a per-surface one; the | ||
| /// composition root hands it to the crash reporter at SDK start. A new | ||
| /// content surface that is not a `UILabel`/`UIImageView`/`WKWebView` must be | ||
| /// added here before it ships. | ||
| public struct MobileSessionReplayMasking { | ||
| private let browserMasking: BrowserStreamReplayMasking | ||
|
|
||
| public init(browserMasking: BrowserStreamReplayMasking = BrowserStreamReplayMasking()) { | ||
| self.browserMasking = browserMasking | ||
| } | ||
|
|
||
| /// All app-owned content surfaces that session replay must mask. | ||
| public var maskedViewClasses: [AnyClass] { | ||
| [ | ||
| GhosttySurfaceView.self, | ||
| SimStreamDisplayView.self, | ||
| CameraPreviewHostView.self, | ||
| ] + browserMasking.maskedViewClasses | ||
| } | ||
| } | ||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use instance-owned replay mask providers.
Both masking declarations use static-only namespaces. Convert them to constructable types with instance-owned
maskedViewClasses, then compose those instances through one injectable owner.Packages/iOS/CmuxMobileBrowserStream/Sources/CmuxMobileBrowserStream/BrowserStreamReplayMasking.swift#L10-L10: replace the static-only browser mask namespace with an instance-owned provider.ios/cmuxPackage/Sources/cmuxFeature/MobileSessionReplayMasking.swift#L18-L18: replace the static-only aggregate namespace and consume the browser provider instance.📍 Affects 2 files
Packages/iOS/CmuxMobileBrowserStream/Sources/CmuxMobileBrowserStream/BrowserStreamReplayMasking.swift#L10-L10(this comment)ios/cmuxPackage/Sources/cmuxFeature/MobileSessionReplayMasking.swift#L18-L18🤖 Prompt for AI Agents
Source: Coding guidelines