Skip to content
Browse files

Fix Spacing lifecycle issue introduced by D3516692

Summary: D3516692 incorrectly assumed that the Spacing object was immutable.  This is not true as it can change in a measure pass on the shadow thread while the UI is displaying some other data.  This fixes it to just pull the values we need and pass them instead of the object.

Reviewed By: foghina

Differential Revision: D3523004

fbshipit-source-id: 056baecf60a9c2f2494d173a3c60396a93b97d42
  • Loading branch information...
Dave Miller Facebook Github Bot 9
Dave Miller authored and Facebook Github Bot 9 committed Jul 6, 2016
1 parent c57eb94 commit 8c9f190038eec838817c7338ac9073f2e1042985
@@ -23,7 +23,10 @@
private final Spannable mText;
private final int mJsEventCounter;
private final boolean mContainsImages;
private final Spacing mPadding;
private final float mPaddingLeft;
private final float mPaddingTop;
private final float mPaddingRight;
private final float mPaddingBottom;

public ReactTextUpdate(
Spannable text,
@@ -33,7 +36,10 @@ public ReactTextUpdate(
mText = text;
mJsEventCounter = jsEventCounter;
mContainsImages = containsImages;
mPadding = padding;
mPaddingLeft = padding.get(Spacing.LEFT);
mPaddingTop = padding.get(Spacing.TOP);
mPaddingRight = padding.get(Spacing.RIGHT);
mPaddingBottom = padding.get(Spacing.BOTTOM);

public Spannable getText() {
@@ -48,7 +54,19 @@ public boolean containsImages() {
return mContainsImages;

public Spacing getPadding() {
return mPadding;
public float getPaddingLeft() {
return mPaddingLeft;

public float getPaddingTop() {
return mPaddingTop;

public float getPaddingRight() {
return mPaddingRight;

public float getPaddingBottom() {
return mPaddingBottom;
@@ -17,7 +17,6 @@
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.csslayout.Spacing;
import com.facebook.react.uimanager.ReactCompoundView;

public class ReactTextView extends TextView implements ReactCompoundView {
@@ -46,12 +45,11 @@ public void setText(ReactTextUpdate update) {
Spacing padding = update.getPadding();
(int) Math.ceil(padding.get(Spacing.LEFT)),
(int) Math.ceil(padding.get(Spacing.TOP)),
(int) Math.ceil(padding.get(Spacing.RIGHT)),
(int) Math.ceil(padding.get(Spacing.BOTTOM)));
(int) Math.ceil(update.getPaddingLeft()),
(int) Math.ceil(update.getPaddingTop()),
(int) Math.ceil(update.getPaddingRight()),
(int) Math.ceil(update.getPaddingBottom()));


0 comments on commit 8c9f190

Please sign in to comment.
You can’t perform that action at this time.