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

Rotating list view causes text to disappear and sometimes causes app to STB #813

Closed
jaygarcia opened this issue Apr 11, 2015 · 8 comments
Closed
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@jaygarcia
Copy link
Contributor

Rotating the list view causes the text to disappear. In some cases, the UIExplorer sample STBs.

Perhaps the Flex layout has something to do with it?

 row : {
        flexDirection   : 'row',
        justifyContent  : 'center',
        padding         : 10,
        backgroundColor : '#F6F6F6',
    },

My App:
stb2

UIExplorer:
stb

@ustun
Copy link

ustun commented Apr 12, 2015

I can confirm, the example UIExplorer project has the same bug.

@siuying
Copy link

siuying commented Apr 14, 2015

Yep this happens.

@drkibitz
Copy link
Contributor

Seeing this in my own layout:
contentContainer: position: 'absolute', left: 50, right: 50, top: 0, bottom: 0
contentColumns: flexDirection: 'row'
contentColumn: flexDirection: 'column', flex: 1
contentColumnText: ...text styles...

If I give contentContainer an explicit width disallowing anything to reflow, text remains visible.

Also if I give contentColumn the style of alignItems: 'flex-start' it allows the containers to reflow, but also prevents the text from wrapping, therefore the text remains visible here as well. This points to something specific in the text view...

Maybe is has to do specifically with alignItems: 'stretch' and the text view, because with this style the text continues to disappear? Just not sure though, these are all just assumptions at this point.

@drkibitz
Copy link
Contributor

Also an important note:
This issue is not related to ListView, or ScrollView, it can be reproduced easily in any View.

@drkibitz
Copy link
Contributor

Tracing things back to this commit 3f6943c, related to changes in Libraries/Text

@drkibitz
Copy link
Contributor

Did some more digging, it looks like it is related to the NSLayoutManager losing it's reference to the NSTextStorage which results in NSLayoutManager returning an empty glyphRange in RCTText's drawRect method.

What's weird is when I compare _textStorage.layoutManagers[0] == _layoutManager I get true. But, _layerManager.textStorage is indeed nil. So the _layoutManager is added to _textStorage, but it does not have a reference back to the receiver, but I'm not sure how this happened.

NSLayoutManager.h says not to set layerManager.textStorage directly, but the funny thing is, when I do this exactly, e.g. _layoutManager.textStorage = _textStorage; inside drawRect, everything seems to work.

This seems like unexpected UIKit behavior to me, what does everyone else think?

@drkibitz
Copy link
Contributor

Finally, I think I've got a fix, we were causing this error in RCTShadowText RCTMeasure function here https://github.com/facebook/react-native/blob/master/Libraries/Text/RCTShadowText.m#L28

Turns out, an NSLayoutManager allows, but does not work correctly when adding to more than one NSTextStorage receiver.

I think I've got a PR brewing I should make shortly.

drkibitz added a commit to drkibitz/react-native that referenced this issue Apr 15, 2015
Also fix RCTShadowText export name.
@chirag04
Copy link
Contributor

+1. Having the same issue. @vjeux

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants