Skip to content

Commit

Permalink
Merge pull request #570 from DataDog/louiszawadzki/RUM-2173/improve-i…
Browse files Browse the repository at this point in the history
…OS-SR-performance

Improve iOS Text Mapper performance
  • Loading branch information
louiszawadzki authored Dec 18, 2023
2 parents 096d285 + 81f979e commit 9555a3b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal class RCTTextViewRecorder: SessionReplayNodeRecorder {
textAlignment: shadow.textAttributes.alignment,
textColor: shadow.textAttributes.foregroundColor?.cgColor,
textObfuscator: textObfuscator(context),
font: shadow.textAttributes.effectiveFont(), // Custom fonts are currently not supported for iOS
font: nil, // Custom fonts are currently not supported for iOS
contentRect: shadow.contentFrame
)
let node = SessionReplayNode(viewAttributes: attributes, wireframesBuilder: builder)
Expand All @@ -79,6 +79,9 @@ internal class RCTTextViewRecorder: SessionReplayNodeRecorder {
}
}

// Black color. This is faster than accessing UIColor.black.cgColor.
let DEFAULT_COLOR = UIColor(white: 0, alpha: 1).cgColor

internal struct RCTTextViewWireframesBuilder: SessionReplayNodeWireframesBuilder {
let wireframeID: WireframeID
let attributes: SessionReplayViewAttributes
Expand All @@ -93,8 +96,6 @@ internal struct RCTTextViewWireframesBuilder: SessionReplayNodeWireframesBuilder
attributes.frame
}

let DEFAULT_FONT_COLOR = UIColor.black.cgColor

// Clipping should be 0 to avoid the text from overflowing when the
// numberOfLines prop is used.
private var clip: SRContentClip {
Expand Down Expand Up @@ -138,7 +139,7 @@ internal struct RCTTextViewWireframesBuilder: SessionReplayNodeWireframesBuilder
// Text alignment is top for all RCTTextView components.
textAlignment: .init(systemTextAlignment: textAlignment, vertical: .top),
clip: clip,
textColor: textColor ?? DEFAULT_FONT_COLOR,
textColor: textColor ?? DEFAULT_COLOR,
font: font,
borderColor: attributes.layerBorderColor,
borderWidth: attributes.layerBorderWidth,
Expand Down

0 comments on commit 9555a3b

Please sign in to comment.