Skip to content

Conversation

j-piasecki
Copy link
Collaborator

Details

In the current implementation, layoutContext is created for every measure of the markdown text input. To construct the context, we need the font size multiplier, which should be read from the UI thread (which we cannot really do by the time we need the result).

This PR updates the implementation to use a thread-local instance of the layout context, which is then updated inside layout method, which receives up-to-date info from React Native. A similar mechanism is used in the RN itself: https://github.com/facebook/react-native/blob/12b2b5610263cb145d1ade8eaf06d8a6e015b10e/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp#L63. This way, the font size multiplier is read only once.

A potential downside to this approach is that when the multiplier changes, the layout context is updated after the measure, potentially leaving a single tree version where the input is measured with the wrong text scale. It's hard to confirm this, though, since React Native doesn't currently support responding to font scale changes correctly (it will be handled in 0.80 behind a feature flag).

Related Issues

GH_LINK

Manual Tests

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant