Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

[ASTextNode] Prompt creation of truncater object when the context object is accessed. - #1110

Merged
appleguy merged 1 commit into
facebookarchive:masterfrom
yury:fix-truncation
Jan 26, 2016
Merged

[ASTextNode] Prompt creation of truncater object when the context object is accessed.#1110
appleguy merged 1 commit into
facebookarchive:masterfrom
yury:fix-truncation

Conversation

@yury

@yury yury commented Jan 25, 2016

Copy link
Copy Markdown
Contributor

See comment

Fixes #865.

attributedString on ASTextNode should be set after all truncationStrings...

@appleguy

Copy link
Copy Markdown
Contributor

@yury what exactly is the dependency here? Why doesn't the truncater get accessed, e.g. [self truncater] get called, at a later point as soon as it is required? Thanks a lot for looking at this!

@appleguy appleguy added this to the 1.9.7 milestone Jan 25, 2016
@appleguy appleguy changed the title Create Truncater with context. So it will actually truncate string [ASTextNode] Prompt creation of truncater object when the context object is accessed. Jan 25, 2016
@yury

yury commented Jan 25, 2016

Copy link
Copy Markdown
Contributor Author

@appleguy as my debugging shows, [self truncater] is called only to get visibleRange to detect links. And it is to late at that moment.

Truncated should be initialized ahead of size calculation so it can actually truncate string in it's initializer.
@tomizimobile patch here #1033 also init truncater ahead.

@yury

yury commented Jan 25, 2016

Copy link
Copy Markdown
Contributor Author

Actual message text

hello
this is
very long
message here
and here

with maximumNumberOfLines = 4, truncationAttributedString = " ..." and additionalTruncationMessage = "read more"

Before fix
screen shot 2016-01-26 at 01 13 51

after
screen shot 2016-01-26 at 01 14 37

@appleguy

Copy link
Copy Markdown
Contributor

@yury thank you for those additional details. It is still mysterious to me why this object has to be created ahead of time and I wonder if there is a later point than init where it can be created, as init may occur on the main thread, but none of our sizing calculations occur there. If you're able to share a test case, I can verify, but it's possible the perf impact of this is negligible with the current factoring of the code (it used to be measurable as suboptimal).

@appleguy

Copy link
Copy Markdown
Contributor

Merging this for correctness now, optimization later with a test case. Please email me at asyncdisplaykit@gmail.com with any other thoughts! cc @tomizimobile

appleguy added a commit that referenced this pull request Jan 26, 2016
[ASTextNode] Prompt creation of truncater object when the context object is accessed.
@appleguy
appleguy merged commit 6bd62cb into facebookarchive:master Jan 26, 2016
@tomizimobile

Copy link
Copy Markdown
Contributor

@appleguy I've tried out master just now, and while the truncation string now appears, it seems that you can't actually interact with it. Using the workaround I talked about in #1033 still seems to work for me.
@yury Are you seeing this same behavior?

@yury

yury commented Jan 28, 2016

Copy link
Copy Markdown
Contributor Author

@tomizimobile will check tomorrow.

@yury

yury commented Jan 29, 2016

Copy link
Copy Markdown
Contributor Author

@appleguy, @tomizimobile confirming that textNodeTappedTruncationToken doesn't called.

And confirming, that @tomizimobile workaround fixes this.

@tomizimobile can you make PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants