-
Notifications
You must be signed in to change notification settings - Fork 26
fix(iOS): proper layout calculation #339
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
base: main
Are you sure you want to change the base?
fix(iOS): proper layout calculation #339
Conversation
|
Hey @IvanIhnatsiuk the changes look promising but we need to make sure absolutely no regressions are introduced. We cannot proceed with the PR no matter how big the performance gains if any of these re-emerge. If it comes to the measuring part, I'll check it on my end. |
|
@szydlovsky Sure and it's obviously clear to me 😄 . I will test all of these scenarios and comeback with update 🙂 |
Screen.Recording.2025-12-18.at.17.57.54.mov
Screen.Recording.2025-12-18.at.18.01.27.mov |
|
@IvanIhnatsiuk okay, we anyway want to test it out really thoroughly. Might be as late as at the beginning of the new year so we'll need some patience here 🙏 |
f72acb5 to
4caf62b
Compare
| - ReactCommon/turbomodule/core | ||
| - SocketRocket | ||
| - Yoga | ||
| - react-native-safe-area-context (5.6.2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, let me know if you want to keep separate screens in the example app or I should remove all of this logic.
NOTE:
Initially, I added it to simplify testing on your side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be removed. If we considered extending example app, we would like to this separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@exploIF Okay, then I will keep it for testing purposes. Once you test it and confirm that there are no issues, I will revert these changes
Summary
This PR simplifies and significantly optimizes text measurement + corrects textKit measurements.
Closes #332
Problems:
All these problems were because we used the
setContentViewmethod, which is not a UIKit method(it was a RN method) that required proper children caculation. However, in our scenario, we just need to know the current content size, and UIKit can calculate the UIScrollView bounds and text content automatically.Why did it happen?
InputTextView Content Size Measurement Issue
Problem Description
The issue was related to our
InputTextView.InputTextViewalways had zero bounds ({0,0}) during layout, which meant that TextKit did not know the actual size of the text container. As a result, TextKit attempted to measurecontentSizeusing an invalid (zero-width) container, which led to incorrect text measurement and layout behavior.This behavior can be verified by placing a breakpoint in the method responsible for computing
contentSizeinsideInputTextView: at that moment, TextKit had no knowledge of the real container size.Root Cause
updateLayoutMetricsdid not properly apply geometry toInputTextViewframe/boundsremained zerotextContainer.sizedid not reflect the actual width of the componentBecause of this,
contentSizewas calculated incorrectly, which caused issues such as:Benchmarks
for the text content like:
Test Plan
Provide clear steps so another contributor can reproduce the behavior or verify the feature works.
For example:
Screenshots / Videos
Initial layout + scrolling
Screen.Recording.2025-12-21.at.18.40.18.mov
Long single paragraph
Screen.Recording.2025-12-21.at.18.45.17.mov
New line insertion:
Please watch these videos at 0.25x speed.
Before
Screen.Recording.2025-12-21.at.18.48.49.mov
After
Screen.Recording.2025-12-21.at.18.46.10.mov
Content size layout measurement (Before)
Uploading Screen Recording 2025-12-21 at 18.55.16.mov…
Error that content size is ambiguous
Compatibility