diff --git a/Sources/LaunchDarklySessionReplay/ScreenCapture/ImageCaptureService.swift b/Sources/LaunchDarklySessionReplay/ScreenCapture/ImageCaptureService.swift index ddc084a..abb0017 100644 --- a/Sources/LaunchDarklySessionReplay/ScreenCapture/ImageCaptureService.swift +++ b/Sources/LaunchDarklySessionReplay/ScreenCapture/ImageCaptureService.swift @@ -54,7 +54,6 @@ public final class ImageCaptureService { let enclosingBounds = windowCaptureManager.minimalBoundsEnclosingWindows(windows) let renderer = windowCaptureManager.makeRenderer(size: enclosingBounds.size, scale: scale) - CATransaction.flush() let maskOperationsBefore = windows.map { maskCollector.collectViewMasks(in: $0, window: $0, scale: scale) } let image = renderer.image { ctx in windowCaptureManager.drawWindows(windows, into: ctx.cgContext, bounds: enclosingBounds, afterScreenUpdates: false) @@ -64,8 +63,12 @@ public final class ImageCaptureService { DispatchQueue.main.async { [weak self, weak maskCollector] in // Move collecting masks after to the next tick guard let self, let maskCollector, shouldCapture else { return } + + let hasMasks = maskOperationsBefore.contains(where: { !$0.maskOperations.isEmpty }) + if (hasMasks) { + CATransaction.flush() + } - CATransaction.flush() let maskOperationsAfter = windows.map { maskCollector.collectViewMasks(in: $0, window: $0, scale: self.scale) } Task { diff --git a/TestApp/Sources/MainMenuView.swift b/TestApp/Sources/MainMenuView.swift index 257580c..31fc0fd 100644 --- a/TestApp/Sources/MainMenuView.swift +++ b/TestApp/Sources/MainMenuView.swift @@ -115,7 +115,8 @@ struct MainMenuView: View { Section { MaskingGridRow(title: "One TextField", uikitAction: { isMaskingUIKitOneFieldEnabled = true - }, swiftUIAction: nil) + }, swiftUIAction: nil).ldMask() + #if os(iOS) MaskingGridRow(title: "Credit Card", uikitAction: { isMaskingUIKitCreditCardEnabled = true @@ -146,6 +147,7 @@ struct MainMenuView: View { isNotebookEnabled = true } .buttonStyle(.borderedProminent) + Button("Storyboard") { isStoryboardEnabled = true }