Skip to content
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

fix: flicker when sensitive text field is on screen #270

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- fix: screen flicker when capturing a screenshot when a sensitive text field is on screen ([#270](https://github.com/PostHog/posthog-ios/pull/270))

## 3.16.0 - 2024-12-03

- fix: deprecate `maskPhotoLibraryImages` due to unintended masking issues ([#268](https://github.com/PostHog/posthog-ios/pull/268))
Expand Down
8 changes: 3 additions & 5 deletions PostHog/Replay/UIView+Util.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@
let renderer = UIGraphicsImageRenderer(size: size, format: rendererFormat)

let image = renderer.image { _ in
// true for afterScreenUpdates so that we capture view *after* any pending animations are committed
// As a side effect, we need to pause view tracker temporarily to avoid recursive calls since this option will cause subviews to layout, which will then trigger another capture
ViewLayoutTracker.paused = true
drawHierarchy(in: bounds, afterScreenUpdates: true)
ViewLayoutTracker.paused = false
/// Note: Always `false` for `afterScreenUpdates` since this will cause the screen to flicker when a sensitive text field is visible on screen
/// This can potentially affect capturing a snapshot during a screen transition but we want the lesser of the two evils here
drawHierarchy(in: bounds, afterScreenUpdates: false)
}

return image
Expand Down
3 changes: 0 additions & 3 deletions PostHog/Replay/ViewLayoutTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import UIKit

enum ViewLayoutTracker {
static var paused = false
private(set) static var hasChanges = false
private static var hasSwizzled = false

static func viewDidLayout(view _: UIView) {
guard !paused else { return }
hasChanges = true
}

static func clear() {
guard !paused else { return }
hasChanges = false
}

Expand Down
Loading