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

Conversation

levi
Copy link
Contributor

@levi levi commented Nov 7, 2015

I had some free time on a plane yesterday and saw this piece of low hanging fruit that didn't require much focus. I would like to contribute an ASLabelNode in the next couple of weeks and updating the backing renderer is a much needed addition before implementing methods like minimumFontSize and adjustsFontSizeToFitWidth.

Some unit tests are failing right now, as it seems that the floating point math doesn't produce consistent results. @appleguy, you might have deeper insight into why this is. Going to dig a bit deeper into the TextKit sizing behavior to see what changed from the original implementation of ASTextNodeRenderer.

There were some API differences. I ended up adding an exclusionPaths attribute to the CKTextKitRenderer, which probably would make sense to contribute back to ComponentKit. isTruncated is reimplemented, as the truncation range is no longer exposed. And I ran into a build error when trying to include ASTextKitRenderer.h in the umbrella AsyncDisplayKit.h, as it seems to be trying to build the header as a C header and is confused where to find the #import <vector> c++ std lib header. I haven't worked much with Xcode's C++ integration, so help would be appreciated.

I removed the legacy tests that were specific to the original renderer API. Naturally, I would like to bring up the tests to speed and need to decide a good testing strategy for this implementation. CK has a great suite of unit tests and there might be some value in copying them over to increase the coverage stats in the project. On the integration side, a snapshot test or two could be valuable, but need to identify possible areas of regression before spending too much time on creating test cases.

Resolves #804

@appleguy
Copy link
Contributor

appleguy commented Nov 7, 2015

Fantastic, thanks @levi! This is something that @ocrickard and I have talked about doing for basically a year. Oliver, if you have a few minutes to skim this or have any notable comments (e.g., known issues or planned work in the CK version) — please do :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, did I write this on the original diff? Must have leaned on my keyboard or somehting :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocrickard
Copy link
Contributor

Hey guys! This looks great. I'm going to have to review this more thoroughly later, but on a first read through looks reasonable to me.

Are you still seeing float math errors here? That's a pretty common thing to see with Text code... inevitably +1's creep in, and the sizes change a little bit. If you point me towards the failing unit test I may be able to help debug.

@levi
Copy link
Contributor Author

levi commented Nov 8, 2015

Thanks for checking this out, @ocrickard. The current ASTextNode unit tests do an initial measurement pass and remeasure, checking the equality of the results. You're right in that they're running into floating point specifics. Here's a link to the first failing one: https://github.com/facebook/AsyncDisplayKit/blob/master/AsyncDisplayKitTests/ASTextNodeTests.m#L100 The other failing test is the one below it.

@appleguy
Copy link
Contributor

appleguy commented Nov 9, 2015

@ocrickard any clue why re-measuring the ASTextNode would produce different results with the new renderer? That seems pretty darn odd to me, although I haven't looked at the implementation for which objects / state are shared. No worries if you're busy right now, we'll eventually figure it out :)

@ocrickard
Copy link
Contributor

Interesting. My guess is that you're hitting a cached value where you
weren't before, but would have to try and repro locally to confirm. Maddie
may be able to review as well.

On Sunday, November 8, 2015, appleguy notifications@github.com wrote:

@ocrickard https://github.com/ocrickard any clue why re-measuring the
ASTextNode would produce different results with the new renderer? That
seems pretty darn odd to me, although I haven't looked at the
implementation for which objects / state are shared. No worries if you're
busy right now, we'll eventually figure it out :)


Reply to this email directly or view it on GitHub
#825 (comment)
.


Oliver Clark Rickard
ocrickard@gmail.com

(707) 536-1352

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the renderer is an implementation detail. I wouldn't put it in the public header...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to include this in just to keep header consistency, but removing it is probably for the best to clean up the 2.0 umbrella file.

@ocrickard
Copy link
Contributor

cc @mboyd1017 can you help review?

Ahh, yeah now I remember. There's a hack in ASTextNode that allows that test to work. It was added by @mboyd1017. Not sure exactly how to fix that in the cached renderer world... perhaps store a value with the calculated size as its key in the renderer cache?

Both CoreText and TextKit will return different values when laid out with one constraint, then recompute the layout with the calculated bounds. Due to a combination of float math, complex line breaking algorithms, and magic... it's inconsistent. The best we can do is workaround it.

BTW, I didn't notice before, but this doesn't pull in the renderer cache. You're gonna miss out on some of the perf and memory benefits without that... but this should be a cleaner implementation to support in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: indentation is off here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

picked

@levi
Copy link
Contributor Author

levi commented Nov 9, 2015

@ocrickard good catch on the LRU cache. I decided not to bring it in this patch just to keep the scope of changes easier to review. I would like to further investigate the best approach of including it in ASDK 2.0 and currently planning to put up a second patch once this lands.

@appleguy
Copy link
Contributor

I agree we don't need the LRU cache right now. The ASDK architecture makes it significantly less necessary, although conceivably beneficial - particularly to accelerate things like full table / collection data reloads.

@levi will you be able to investigate the failing test soon? It looks like some rebasing is required as well, so I'd like to get this landed ASAP so we don't have the surface area exposed to merge conflicts.

@levi
Copy link
Contributor Author

levi commented Nov 15, 2015

@appleguy I'll look into this tonight and get it to a landable stage. Thanks for the ping!

@ocrickard
Copy link
Contributor

Hey guys, yeah that sounds reasonable to me!

I'm not going to have time to help debug the test this weekend or probably this week. Good luck @levi!

@levi levi force-pushed the levi/text-renderer branch from 9f28b02 to fb2333d Compare November 15, 2015 08:08
@levi
Copy link
Contributor Author

levi commented Nov 15, 2015

All tests passing but the framework smoke test. I forgot where I need to add the new files to make it green.

To make the floating point inconsistencies pass, I added a simple cgsize comparison method to take into account a small delta of change. CK has a large body of snapshot tests that test the layout behavior of their text and label nodes. I would like to spend sometime porting those over to ASDK once this PR lands. I think using snapshots would be a much more accurate way of testing the final result of the ASTextNode.

@levi
Copy link
Contributor Author

levi commented Nov 16, 2015

Tests fixed, thanks for you help @appleguy!

@ocrickard
Copy link
Contributor

Awesome. What was the issue?

Sent from my iPhone

On Nov 15, 2015, at 7:04 PM, Levi McCallum notifications@github.com wrote:

Tests fixed, thanks for you help @appleguy!


Reply to this email directly or view it on GitHub.

@levi
Copy link
Contributor Author

levi commented Nov 16, 2015

@ocrickard linking the newly added files to the iOS framework. Unrelated to the actual implementation of this diff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should rename these functions, or otherwise retain the CK filename and place such files in a directory that designates them as unmodified CK ports.

@appleguy
Copy link
Contributor

@levi - some brief notes I wrote on the plane home. I'm going to merge this as-is, and the notes can be for a followup (we can make a task referencing this PR if you're busy!)

@ocrickard - this is really some serious software. Thanks for all your great work on it — both the original ASDK version, and the robust + unique refinements you made with CK! It's really cool to see such workhorse code be valuable in both projects.

@levi
Copy link
Contributor Author

levi commented Nov 28, 2015

@appleguy great to hear it! Probably won't be able to get to these until next weekend. A task pointer would definitely be helpful, thanks.

@levi levi force-pushed the levi/text-renderer branch from 6c2cfff to 04ad021 Compare November 30, 2015 14:56
@levi
Copy link
Contributor Author

levi commented Nov 30, 2015

No problem. Looks like some good ol' pbxproj issues. This branch should be good to merge now. I updated a few of the renaming requests above, however, still need to find a block of time where I can implement better tests and update this with the latest fixes from CK.

@appleguy
Copy link
Contributor

@levi I'm ready to land this - but for some reason it is tripping up on my Visible range stuff?

"Undefined symbols for architecture x86_64:
"OBJC_CLASS$_ASRangeHandlerVisible", referenced from:
objc-class-ref in libAsyncDisplayKit.a(ASRangeController.o)
ld: symbol(s) not found for architecture x86_64
"

@levi
Copy link
Contributor Author

levi commented Nov 30, 2015

Oh man, my failed builds 😓. I'll have some time this afternoon to take a look.

@levi
Copy link
Contributor Author

levi commented Nov 30, 2015

Alright, this one should be a winner 😸

@appleguy
Copy link
Contributor

appleguy commented Dec 1, 2015

WOO-HOO!!!

appleguy added a commit that referenced this pull request Dec 1, 2015
Update ASTextNode renderer with the latest derivative of it developed for ComponentKit
@appleguy appleguy merged commit 771eca5 into facebookarchive:master Dec 1, 2015
@levi
Copy link
Contributor Author

levi commented Dec 1, 2015

Awesome! I'm happy to see this get in—finally! 💮

peter-iakovlev pushed a commit to peter-iakovlev/AsyncDisplayKit that referenced this pull request Mar 12, 2018
…e#825)

* A few small fixes plus a failing test for ASTextNode

* Change the approach

* Update changelog

* Eh screw null_resettable

* No need for changelog now
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