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

Breaking: Always use AttributedStringBox instead of AttributedString in TextLayoutManager #46104

Closed
wants to merge 1 commit into from

Conversation

NickGerleman
Copy link
Contributor

Summary:
We want to use PrecomputedText to store glyph-level measurements on underlying Android Spannable. This means we need to consistently reuse the same Spannable, instead of recreating them on measurement.

We have an opaque cache ID used by Android, for spannables originating from uncontrolled TextInput on UI-thread side. We also have AttributedStringBox, for a kind of similar purpose on iOS, which allows passing opaque pointer to the TextLayoutManager. This is only used for the measure function.

This change makes us consistently use AttributedStringBox at the TextLayoutManager boundary, to let us migrate calls across TextLayoutManager to all pass opaque handle to underlying Spannable we will store, instead of passing the AttributedString each time. For now, every place previously passing an AttributedString value still passes one.

There were also some egregious cases of accepting very large structures by value, causing unneeded copies. I changed the APIs to accept anything potentially larger than two pointers to pass by reference instead.

This change is technically breaking, to any 3p code calling into TextLayoutManager (IIRC live-markdown exposed prefabs for this, but should be able to adapt fairly easily).

Changelog:
[General][Breaking] - Always use AttributedStringBox instead of AttributedString in TextLayoutManager

Differential Revision: D61484999

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Aug 19, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61484999

@NickGerleman
Copy link
Contributor Author

FYI @j-piasecki @tomekzaw

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61484999

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Aug 19, 2024
…in TextLayoutManager (facebook#46104)

Summary:
Pull Request resolved: facebook#46104

We want to use `PrecomputedText` to store glyph-level measurements on underlying Android Spannable. This means we need to consistently reuse the same Spannable, instead of recreating them on measurement.

We have an opaque cache ID used by Android, for spannables originating from uncontrolled TextInput on UI-thread side. We also have `AttributedStringBox`, for a kind of similar purpose on iOS, which allows passing opaque pointer to the `TextLayoutManager`. This is only used for the `measure` function.

This change makes us consistently use `AttributedStringBox` at the TextLayoutManager boundary, to let us migrate calls across TextLayoutManager to all pass opaque handle to underlying Spannable we will store, instead of passing the AttributedString each time. For now, every place previously passing an AttributedString value still passes one.

There were also some egregious cases of accepting very large structures by value, causing unneeded copies. I changed the APIs to accept anything potentially larger than two pointers to pass by reference instead.

This change is technically breaking, to any 3p code calling into TextLayoutManager (IIRC live-markdown exposed prefabs for this, but should be able to adapt fairly easily).

Changelog:
[General][Breaking] - Always use AttributedStringBox instead of AttributedString in TextLayoutManager

Differential Revision: D61484999
…in TextLayoutManager (facebook#46104)

Summary:
Pull Request resolved: facebook#46104

We want to use `PrecomputedText` to store glyph-level measurements on underlying Android Spannable. This means we need to consistently reuse the same Spannable, instead of recreating them on measurement.

We have an opaque cache ID used by Android, for spannables originating from uncontrolled TextInput on UI-thread side. We also have `AttributedStringBox`, for a kind of similar purpose on iOS, which allows passing opaque pointer to the `TextLayoutManager`. This is only used for the `measure` function.

This change makes us consistently use `AttributedStringBox` at the TextLayoutManager boundary, to let us migrate calls across TextLayoutManager to all pass opaque handle to underlying Spannable we will store, instead of passing the AttributedString each time. For now, every place previously passing an AttributedString value still passes one.

There were also some egregious cases of accepting very large structures by value, causing unneeded copies. I changed the APIs to accept anything potentially larger than two pointers to pass by reference instead.

This change is technically breaking, to any 3p code calling into TextLayoutManager (IIRC live-markdown exposed prefabs for this, but should be able to adapt fairly easily).

Changelog:
[General][Breaking] - Always use AttributedStringBox instead of AttributedString in TextLayoutManager

Differential Revision: D61484999
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D61484999

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in ee597bf.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @NickGerleman in ee597bf

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants