From 4c548af5204ffc62f68d156affd2f37203825b2a Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Wed, 20 Nov 2024 09:37:40 +0100 Subject: [PATCH] fix: read accessibilityLabel from parent's view to avoid performance hit on RN (#259) * fix: read accessibilityLabel from parent's view to avoid performance hit on RN * fix --- CHANGELOG.md | 2 ++ PostHog/Replay/UIView+Util.swift | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4486998e8..ccb633cd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Next +- fix: read accessibilityLabel from parent's view to avoid performance hit on RN ([#259](https://github.com/PostHog/posthog-ios/pull/259)) + ## 3.15.5 - 2024-11-19 - fix: properly mask SwiftUI Text (and text-based views) ([#257](https://github.com/PostHog/posthog-ios/pull/257)) diff --git a/PostHog/Replay/UIView+Util.swift b/PostHog/Replay/UIView+Util.swift index 35e9f1c0c..08f713e3d 100644 --- a/PostHog/Replay/UIView+Util.swift +++ b/PostHog/Replay/UIView+Util.swift @@ -22,7 +22,9 @@ if let identifier = accessibilityIdentifier { isNoCapture = checkLabel(identifier) } - if let label = accessibilityLabel, !isNoCapture { + // read accessibilityLabel from the parent's view to skip the RCTRecursiveAccessibilityLabel on RN which is slow and may cause an endless loop + // see https://github.com/facebook/react-native/issues/33084 + if let label = super.accessibilityLabel, !isNoCapture { isNoCapture = checkLabel(label) }