-
Notifications
You must be signed in to change notification settings - Fork 18
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
Update to latest yoga #54
Conversation
@nicoburns wow, very kind of you to update this. It's true this isn't really maintained anymore, but for sure I will still accept PRs! This was one of my earlier Rust projects, and I see I haven't added any github actions CI. I'll try to add some basic Actions files so we can be more confident in future changes. |
@nicoburns if you prefer, I can fix up formatting and compiler warnings in a separate PR with the addition of github actions. Not sure if that would make this easier or harder for you though, as it'll likely create some merge conflicts. |
Here's the PR for CI, I'll let you decide if you want to merge it before or after your PR |
d3d4efe
to
48063c1
Compare
@bschwind Ah, amazing. This is a much better response than I was expecting! I think it makes sense to merge your PR first. The first commit of my PR is to upgrade to the 2021 edition of Rust. It may also make sense to apply that as part of your PR. I've rebased my PR on top of yours, so you could cherry pick that commit if you want. Alternatively, I just applied the automated migration, which you could easily do yourself:
cargo fix --edition
cargo +nightly fmt
Once that is applied and your PR is merged, you'll find that the changes in my PR are actually pretty minimal. But probably we ought to try to fix the tests before merging it? Computations returning |
@nicoburns Thanks! I'll go ahead and apply the edition changes and such so that your PR is purely upgrading yoga itself. Although this crate isn't abandoned, it definitely isn't actively developed like you suspected. The pure-Rust solution in taffy is much preferred. I still like maintaining the Rust crates I have open sourced though! |
@nicoburns Okay, I've updated the edition, and pushed the changes to |
Agreed, let's see if it's something easy to fix. |
8a89477
to
bd50f98
Compare
Ok, I've found the main issue. Which is that the latest version of yoga is no longer designed to be compiled with |
fca0f66
to
ea0e4cd
Compare
Update: Inspecting the generated tests for C++, it seems that they contain the values that Yoga is actually computing. Presumably Chrome has changed it's behaviour on these tests since yoga last updated their gentests. I'm going to manually adjust these tests to match those in the upstream yoga project. This is now good to go as far as I'm concerned (modulo the fact that the build is currently failing in CI - I'm not sure why that is, it's working fine for me locally. Possibly a macOS vs Linux difference?) |
A feature was added to bindgen to address the build issue we're seeing (rust-lang/rust-bindgen#2185). But unfortunately enabling it doesn't seem to fix the issue. I've asked for help here: rust-lang/rust-bindgen#2157, but otherwise I'm afraid I'm at a bit of a loss as how to fix this error. Doesn't help at all that it doesn't reproduce locally. |
@nicoburns do you know of a way on github to approve all future CI runs for you on this PR? I know you're adding things and trying them out, but having to wait for me to approve CI runs probably slows down the experimentation a lot. |
d56c0ae
to
e171f48
Compare
I'm not sure. I suspect you'd have to approve my user rather than the PR (because I could of course push anything to the PR if I wanted to). It says "First-time contributors need a maintainer to approve running workflows", so I suspect once I have some code merged into the repo that will fix this. I'm actually not blocked on this though, because my "fork" (https://github.com/nicoburns/yoga-rs) seems to be independently running the actions and this doesn't seem to require your approval (I guess because the CI is so simple and there are no secrets required, github can make it "just work"?) |
Ok, something super weird is going on here. I am able to build absolutely fine locally on all of the following:
Test procedureInstall pre-requisites:
Clone repoAside: working with submodules is kinda a pain. I wonder if it would be worth considering vendoring the yoga source instead? git clone --recursive https://github.com/bschwind/yoga-rs
git remote add nico https://github.com/nicoburns/yoga-rs
git fetch nico
git checkout update-to-latest-yoga
git submodule update --init --recursive --remote
git restore . --recurse-submodules Run testscargo test AnalysisI think this must have something to do with the CI setup. One would suspect some kind of caching meaning the latest version of the build script isn't getting run. But the CI configuration doesn't seem to be using any caching at all. And I changed the VM image in one commit, which would surely reset any cache. |
Ok, I got it! If I am understanding things correctly, CI was defaulting to linking against If you approve the latest CI runs then they should now run correctly, and this PR will be passing CI :) |
2599847
to
519d7b1
Compare
@nicoburns great work on investigating and solving this! I'll try to review it later today and get it merged. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Just one small question.
Thanks for the effort in getting this working on the latest yoga version!
20ae8cb
to
a007243
Compare
Full commit hash: ba27f9d1ecfa7518019845b84b035d3d4a2a6658
- Don't compile with --ffast-math - Add manually_drop_union() option - Add .default_non_copy_union_style(NonCopyUnionStyle::ManuallyDrop) option - Bump bindgen rustc target version to 1.47 - Force bindgen into C++ mode (Yoga headers use .h rather than .hpp, so this may not be auto-detected) - Add -stdlib=libc++ option
…n with upstream yoga
a007243
to
17b50a9
Compare
Thanks for your hard work on this, @nicoburns! |
I realise this project isn't really maintained anymore (at least it looks that way), but over at Taffy we're keen on benchmarking against Yoga, and this library would seem to be the obvious way to do it. However, it only seems fair to benchmark against the latest version of yoga. So I thought I'd try to see how hard it was to update (not that hard).
35f3335efc88efced75aa1db1bb379cf0872831a
, which was the latest on the main branch as of 15th December 2022YGPositionStatic
variant toYGPosition
enum (especially important because it's added to the start of the enum, renumbering the other variants)YGGutter
set_row_gap
,get_row_gap
,set_column_gap
,get_column_gap
,set_gap
, andget_gap
functions to allow setting and getting gutters using (YGNodeStyleSetGap
andYGNodeStyleGetGap
).There are currently 21 tests failing, which I haven't dug into too deeply. They all seem to be to do with absolute position, and they seem to be returning
NaN
which isn't great.