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

Improve iOS Text Mapper performance #570

Merged
Merged
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
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
Comment on lines +82 to +83
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL :)


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