[Fabric] Fix text input rendering crashing by using layout metrics pixelScaleFactor #1817
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
Summary
The
<TextInput />
component in fabric was querying the pixel scale factor through the window. But since fabric does not guarantee that host views are added to a window when being created and/or inserted, the TextInput views don't have a window and the return scale was 0.0 which caused crashes while loading RNTester.This changes the behavior for fabric by adding a
pixelScaleFactor
to theRCTBackedTextInputViewProtocal
so that the component view can provide the layout metrics pixel scale factor to the backing text input view.The behavior on Paper stays unchanged since the
pixelScaleFactor
won't be set and the scale defaults back to using the window query (self.window.backingScaleFactor
).Changelog
[macOS] [FIXED] - Fix text input rendering crashing on fabric
Test Plan
Tested by running RNTester on macOS with paper and fabric (
RCT_NEW_ARCH_ENABLED=1
) and launching the TextInput example.Without the fix RNTester fabric crashes with the following exception:
With the fix in paper:
With the fix in fabric: