-
Notifications
You must be signed in to change notification settings - Fork 23
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
[write-fonts] reproduce and fix non deterministic gvar serialization #750
Conversation
Meant to reproduce the issue discussed at googlefonts/fontc#647 If we are lucky enough the CI should fail, otherwise flip the coin again and you'll see...
nice, it did fail the first time :) https://github.com/googlefonts/fontations/actions/runs/7277928604/job/19831021279?pr=750
|
…s is deterministic Fixes googlefonts/fontc#647
Finally it took me a few rounds but I managed to also make the CI randomly pass without actually changing anything :) https://github.com/googlefonts/fontations/actions/runs/7277928604/job/19831276618 |
This is to match Python's max() built-in that returns the first item when multiple items are maximum, whereas the Rust Iterator::max_by_key returns the last. Both would work, but this way we match Python fonttools more closely.
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.
Good find cosimo, and I think that matching the behaviour of fonttools is the right call.
This was interesting, and I'm glad it made me go and look more closely into the rust HashMap implementation. :)
This particular test glyph is funny: basically, there are 7 tuple variations, 5 of them have PackedPointNumbers::All, 2 of them have PackedPointNumbers::Some([1, 3]). Using either one as the shared point numbers will save the same number of bytes (4 in this particular case). |
Oh one other idea here: you should be able to get closer to ensuring that this test fails consistently by just running it in a loop for some number of iterations. (and another clarification is that (if I'm understanding correctly) the hashmap does not use a new seed on each execution, but each call to |
oh good to know.
good point, but I think now that I fixed it it's no longer going to fail/pass inconsistently so maybe it's not worth doing the loop any more? |
Meant to reproduce the issue discussed at googlefonts/fontc#647
If we are lucky enough the CI should fail, otherwise flip the coin again and you'll see...