-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[p5.js 2.0 Bug Report]: Visual Tests Failed #7823
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
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you! |
Thanks for raising this @pnngocdoan ! Some of the typography tests have been a flaky test before, and this is a problem that is looking for a volunteer. Are you interested in investigating or fixing this? (One previously discussed possible fix has been to look into how fonts are loaded and if there's issues with that - loading fonts from google urls, or some other issue. This only seems to occur with text, so that's why the investigation could start with text loading.) |
Hi @ksen, so sorry for taking so long to reply. I was out of town for my graduation. I’m currently applying for the grant to help build a better visual test suite so I’ve been exploring the overall testing infrastructure since I feel like p5.js already has a pretty comprehensive setup. I’ve been focusing on the comparison algorithms because initially I thought they might be behind the flakiness (I happened to find another bug and I’ll be raising an issue on this soon!). But you’re right that the problem seems to only affect text. I haven’t had the chance to look specifically into font loading yet as I’ve been catching up from travel and wrapping up my application, but I’d love to dig into it more soon. |
Thanks for the update @pnngocdoan ! No worries, please feel free to message here if you're ready to work on this at some point in the future. In the meantime, if someone else is keen to get started, they are also welcome to comment and volunteer! |
Hi, thanks for raising this issue! I've been looking into the repo too as I am applying for the same grant - I wish you the best of luck with your proposal! I wasn't able to replicate this particular issue, though I have some suggested changes, which I have tested locally - my additions haven't broken anything at the least! 😆 My analysis is that this issue is likely caused by asynchronous Web Font loading. There is a possibility that while the loadFont() function has been successfully resolved, the font binary is still being downloaded or parsed by the browser. Thus, the call to To mitigate this, we can try using An alternative mitigation would be to self-host the font files as with the other local fonts, at least where the test does not explicitly require the use of a Google Font URL. This would eliminate the need for the above code. @ksen0 I noticed a couple other visual tests in typography.js also use Web Fonts besides |
We currently call Lines 947 to 951 in d51184b
|
My understanding is that the while I had a spin at adding the following lines and ran 50+ iterations of tests with no failures. While I feel confident about the fix, I would equally treat it with some scepticism as I had not been able to replicate the issue in the first place. // ensure the font is ready to be rendered
await document.fonts.ready;
await new Promise(r => requestAnimationFrame(r)); Full commit: |
Since CI seems to be able to reproduce this more often, maybe you could make a PR and I can try manually rerunning tests for the PR a few times to see if it keeps passing? I'd also ideally start with just the |
Thanks Dave, I'm happy to do that, so feel free to assign it to me and I'll make a PR. |
Thanks @sophyphile! |
Uh oh!
There was an error while loading. Please reload this page.
Most appropriate sub-area of p5.js?
p5.js version
No response
Web browser and version
No response
Operating system
No response
Steps to reproduce this
Steps:
npx vitest run
the textWeight visual test failed:npx vitest run -t 'textWeight'
, some time it passed some time not:The text was updated successfully, but these errors were encountered: