From 54f5c8c26ca4ca83d6d90dcede8a59ee96fb3ccb Mon Sep 17 00:00:00 2001 From: Alfonso Curbelo Date: Thu, 17 Feb 2022 13:44:43 -0800 Subject: [PATCH] Fixed - Text with adjustsFontSizeToFit changes the text layout infinitely (#33135) Summary: Fixes the infinite loop explained in the issue https://github.com/facebook/react-native/issues/33129 by reverting commit 59021521e7aba0f70b91b5c7778ccdd1b30eaae4. PR https://github.com/facebook/react-native/pull/31538. `onCollectExtraUpdates` is part of the node update cycle. By marking the node as updated `markUpdated()` in `onCollectExtraUpdates` we are restarting the update infinitely. Unfortunately, reverting this PR also reintroduces the original issue https://github.com/facebook/react-native/issues/30717 which IMO is minor compared to the infinite loop. ## Changelog [Android] [Fixed] - Text with adjustsFontSizeToFit changes the text layout infinitely Pull Request resolved: https://github.com/facebook/react-native/pull/33135 Test Plan: I added a console.log to the Text `onTextLayout` in [packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js ](https://github.com/facebook/react-native/blob/main/packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js) to see if the infinite loop is gone. ![image](https://user-images.githubusercontent.com/3791120/154523914-e6aa7cf5-7a1c-488f-a392-898f4c85a833.png) ![Screen Shot 2022-02-17 at 11 20 31 AM](https://user-images.githubusercontent.com/3791120/154524274-880c3bed-d2c6-456b-8947-42e75793c424.jpg) ``` Reviewed By: ShikaSD Differential Revision: D34310218 Pulled By: lunaleaps fbshipit-source-id: 0d40f49d15c562ec25983145897bd95dc182f897 --- .../com/facebook/react/views/text/ReactTextShadowNode.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java index 85158359891..4e67070aca4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java @@ -343,11 +343,6 @@ public class ReactTextShadowNode extends ReactBaseTextShadowNode { mJustificationMode); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } - - if (mAdjustsFontSizeToFit) { - // Nodes with `adjustsFontSizeToFit` enabled need to be remeasured on every relayout. - markUpdated(); - } } @ReactProp(name = "onTextLayout")