From 591c3349f2f11113cf85f323c26a6db159e30fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Conte=20Mac=20Donell?= Date: Mon, 16 Dec 2024 16:05:00 -0800 Subject: [PATCH] Move screenshots to the main thread (#161) --- WORKSPACE | 4 ++-- .../source/replay/SessionReplayTarget.swift | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 28e872d7..3d9f4e44 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -15,8 +15,8 @@ apple_support_dependencies() http_archive( name = "build_bazel_rules_apple", - sha256 = "62847b3f444ce514ae386704a119ad7b29fa6dfb65a38bff4ae239f2389a0429", - url = "https://github.com/bazelbuild/rules_apple/releases/download/3.8.0/rules_apple.3.8.0.tar.gz", + sha256 = "352428421c89dba8859055c3e1ba42f742c224544bf0e196c926d1cf44a2d726", + url = "https://github.com/bazelbuild/rules_apple/releases/download/3.16.1/rules_apple.3.16.1.tar.gz", ) http_archive( diff --git a/platform/swift/source/replay/SessionReplayTarget.swift b/platform/swift/source/replay/SessionReplayTarget.swift index 96997178..bfc290c9 100644 --- a/platform/swift/source/replay/SessionReplayTarget.swift +++ b/platform/swift/source/replay/SessionReplayTarget.swift @@ -51,18 +51,17 @@ extension SessionReplayTarget: CapturePassable.SessionReplayTarget { return } - let layer = window.layer + let format = UIGraphicsImageRendererFormat() + format.scale = 1.0 + + let start = Uptime() let bounds = UIScreen.main.bounds.size + let jpeg = UIGraphicsImageRenderer(size: bounds, format: format) + .jpegData(withCompressionQuality: 0.1) { context in + window.layer.render(in: context.cgContext) + } self.queue.async { [weak self] in - let start = Uptime() - let format = UIGraphicsImageRendererFormat() - format.scale = 1.0 - - let renderer = UIGraphicsImageRenderer(size: bounds, format: format) - let jpeg = renderer.jpegData(withCompressionQuality: 0.1) { context in - layer.render(in: context.cgContext) - } self?.logger?.logSessionReplayScreenshot( screen: SessionReplayCapture(data: jpeg), duration: Uptime().timeIntervalSince(start)