Closed Bug 1965482 Opened 1 year ago Closed 1 year ago

"mach wpt" always takes ~7s during setup in "install_darwin_font"

Categories

(Testing :: web-platform-tests, defect)

defect

Tracking

(firefox142 fixed)

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: whimboo, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

This is causing a huge delay for me locally each time when I run mach wpt jobs. I thought first it might be related to VCS (git or hg) but as it looks like the real underlying issue is related to the installation of the darwin fonts on MacOS.

I just found out about the ./mach --profile-command global argument and created a profile.

Here the stack with the first 10 frames that show the total time:

449	7.3	0.01626	    7.3	    0.01626	  ~:0(<method 'read' of '_io.BufferedReader' objects>)
40	3.958   0.09895	    3.958	  0.09895	  ~:0(<method 'acquire' of '_thread.lock' objects>)
25	0.3813	0.01525	    0.3813	0.01525	  ~:0(<method 'control' of 'select.kqueue' objects>)
143	0.2879	0.002014	0.2879	0.002014	~:0(<built-in method posix.waitpid>)
399	0.2705	0.0006779	0.2705	0.0006779	~:0(<built-in method builtins.compile>)
112358	0.2225	1.98e-06	0.2225	1.98e-06	~:0(<built-in method posix.stat>)
324642	0.2177	6.705e-07	0.3087	9.51e-07	<frozen posixpath>:71(join)
134309	0.1914	1.425e-06	0.3174	2.363e-06	parse.py:432(urlsplit)
32	0.1616	0.005049	0.1616	0.005049	~:0(<built-in method posix.read>)
388659	0.1596	4.105e-07	0.1709	4.398e-07	parse.py:110(_coerce_args)

Most time ~4s is spent alone in acquiring the lock for a thread.

In CI it is unable to install the font because it is most likely not installed on the workers. But this attempt itself also takes about 30s:

https://treeherder.mozilla.org/logviewer?job_id=507347572&repo=mozilla-central&lineNumber=858-859

[task 2025-05-09T06:56:26.363Z] 06:56:26     INFO - mozversion platform_version: 140.0a1
[task 2025-05-09T06:56:53.250Z] 06:56:53  WARNING - Unable to install font: Ahem.ttf

As James pointed out the tests, that require that font, have probably moved to webfonts so that the installation is probably not needed anymore. Lets push a try build with the font installation disabled on all platforms.

I pushed to try to see what happens when the font is not getting installed:
https://treeherder.mozilla.org/jobs?repo=try&revision=c5dab86e9cf736f17ebba6f4d04aec9d4539a279

A final patch should probably made against the upstream repository to see possible regressions in other browsers.

(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #2)

I pushed to try to see what happens when the font is not getting installed:
https://treeherder.mozilla.org/jobs?repo=try&revision=c5dab86e9cf736f17ebba6f4d04aec9d4539a279

This doesn't look good and points out that we are still required to install the font? Emilio or Jonathan, do you may know more if we are still required to have the system installed font?

A final patch should probably made against the upstream repository to see possible regressions in other browsers.

As talked to James a good to go patch for now would be to force not installing the font at all by using --no-install-fonts in our CI. Later on we could check what to do upstream.

Flags: needinfo?(jfkthame)
Flags: needinfo?(emilio)

It seems those tests need generally fixing? Though the SVG first-letter test might hint at a bug in Gecko.

Most of them should be fixed by doing something like document.fonts.ready.then(() => checkLayout(...)) rather than just checkLayout(...) or so.

Flags: needinfo?(emilio)

Is this only the Ahem font that install_darwin_font is trying to install, or are there any others?

In general tests are supposed to use Ahem as a webfont but I'm pretty sure I've seen some that haven't been updated so they still assume it's installed locally.

When it's used as a webfont, it's necessary to ensure it has loaded before scripts try to examine layout, etc., so as Emilio says in comment 5, a bunch of tests need to wait for document.fonts.ready. They currently pass with Ahem installed locally because the CSS includes src: local("Ahem"), which loads synchronously, but if it's not available they fall back to a src: url(....) rule, which loads async.

Picking an example at random, I checked locally that css/css-sizing/keyword-sizes-for-intrinsic-contributions.html behaves as expected if the checkLayout call is wrapped with document.fonts.ready.then(...), and I'd expect the same to be true for a bunch of others.

Flags: needinfo?(jfkthame)

(In reply to Jonathan Kew [:jfkthame] from comment #6)

Is this only the Ahem font that install_darwin_font is trying to install, or are there any others?

Yes, this is only for Ahem which is the only font that is actually getting installed:

https://searchfox.org/mozilla-central/rev/be684f13a4ce71e7ca5e0b354a0f56a665842922/testing/web-platform/tests/tools/wptrunner/wptrunner/wptrunner.py#407-415

In general tests are supposed to use Ahem as a webfont but I'm pretty sure I've seen some that haven't been updated so they still assume it's installed locally.

When it's used as a webfont, it's necessary to ensure it has loaded before scripts try to examine layout, etc., so as Emilio says in comment 5, a bunch of tests need to wait for document.fonts.ready. They currently pass with Ahem installed locally because the CSS includes src: local("Ahem"), which loads synchronously, but if it's not available they fall back to a src: url(....) rule, which loads async.

Picking an example at random, I checked locally that css/css-sizing/keyword-sizes-for-intrinsic-contributions.html behaves as expected if the checkLayout call is wrapped with document.fonts.ready.then(...), and I'd expect the same to be true for a bunch of others.

I checked this test as well and I don't get it to pass even with using document.fonts.ready.then(). To replicate I've disabled my locally installed Ahem font via the Font Book application and then run the test. But it's always failing for me.

Is that some work one of you could help us with to update? I'm happy to take the rest of the work to update wptrunner not installing the font. I would appreciate. Thanks.

I've got a stack of patches that I believe will address most of the issues here, though try is currently closed so I don't have an up-to-date run to check them all yet. I'll file a separate bug (blocking this one) for the test updates and start posting fixes there.

Depends on: 1966668

Also note that we actually never uninstall / remove the font after the tests are finished which means that the font remains on the users system. Removing it manually and running mach wpt again shows the following warning in the shell:

0:10.68 WARNING Unable to install font: Ahem.ttf

Looks like we are even failing to install the font nowadays? If we don't have to install it anymore we may be able to remove this code so that no traces are left behind.

Actually, I believe we are installing it but the check in install_darwin_font doesn't see it, and then we end up not removing it.

Depends on: 1967315
Depends on: 1967954

Just to update here, once bug 1967954 is landed I believe it will be OK to disable the installation of Ahem, and our CI test jobs should stay green. (A recent try run, including fixes except for bug 1967954, is at https://treeherder.mozilla.org/jobs?repo=try&revision=ebfe7999c004a89cd10fe31c8b5d36168b4be304)

As mentioned by Jonathan on Matrix it would probably be better to remove the local("Ahem") source from ahem.css first, so that it only attempts to load the file resource, never a locally-installed font. It's still possible that "unreliable" tests (that fail to wait for document.fonts.ready) may pass in some browsers/some of the time, as they'll depend on the exact timing of resource loads.

And to add, this is a change that we should do upstream in the wpt repository to see if other vendors don't have issues with it. Then we wait for the downstream sync for follow-up work.

Jonathan, based on the following test results for Nightly stability there are more tests that use the Ahem font and do not wait for it to be loaded and are failing. Mind having a look? Thanks.

Flags: needinfo?(jfkthame)

Which tests are you concerned about exactly? In the results there, I see two /css-page/monolithic-overflow-*-print.html tests are reported as being "slow", though not actually failing. Those are print tests, which means it's not surprising they're quite slow, and I guess loading Ahem as a webfont rather than via src:local() would make them a little slower than before, although it shouldn't be very much different.

It looks like WPT has a <meta name="timeout" content="long"> tag; does adding that to these test files stop the harness complaining?

Was there anything else raising concerns? Those "slow test" warnings were all I noticed, and they're not actually failures AFAICS.

Flags: needinfo?(jfkthame)

You need to further scroll down to actual test results. The following tests have failures:

  • /soft-navigation-heuristics/softnav-after-lcp-paint-larger-than-viewport.tentative.html
  • /soft-navigation-heuristics/softnav-after-lcp-paint.tentative.html
  • /soft-navigation-heuristics/softnav-before-lcp-paint.tentative.html
  • /soft-navigation-heuristics/softnav-between-lcp-render-and-paint.tentative.html
  • /svg/interact/scripted/svg-pointer-events-bbox.html
  • /svg/struct/scripted/svg-getIntersectionList-001.svg
  • /svg/text/scripted/getcharnumatposition-slr.tentative.html
  • /svg/text/scripted/getstartpositionofchar.html
  • /svg/text/scripted/textpath-textlength-text-anchor-001.tentative.svg

Aren't those pre-existing timeouts/failures, though? There appear to be corresponding .ini files in mozilla-central under /testing/web-platform/meta/ showing that they're expected issues.

The severity field is not set for this bug.
:jgraham, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(james)
Severity: -- → S3
Flags: needinfo?(james)

(In reply to Jonathan Kew [:jfkthame] from comment #18)

Aren't those pre-existing timeouts/failures, though? There appear to be corresponding .ini files in mozilla-central under /testing/web-platform/meta/ showing that they're expected issues.

Ok, so we probably have to check the actual stability results upstream which compares the results to main:

As it can be seen a couple of tests seem to fail now. Would you have a chance to check if those are valid?

Interesting is that /svg/text/scripted/getstartpositionofchar.html is not listed there. It also started to fail for Chrome (logs) when we remove local() for the Ahem font. For us it's expected to fail at the moment, but not sure what the right behavior is here.

Flags: needinfo?(jfkthame)

Try run with patches that aim to address the issues in comment 20:
https://treeherder.mozilla.org/jobs?repo=try&revision=445e95306962e26662346c5a6289f9bd66f299c9
If this looks good, we can take it to a WPT PR for further testing.

Flags: needinfo?(jfkthame)

(In reply to Jonathan Kew [:jfkthame] from comment #22)

Let's see how this goes: https://github.com/web-platform-tests/wpt/pull/53444

This PR has now merged upstream, so once that is sync'd back to our tree, I think it should be possible to proceed with disabling the local Ahem installation.

That's great to see Jonathan! The downstream sync will actually happen via bug 1976337.

Depends on: 1976337

(In reply to Jonathan Kew [:jfkthame] from comment #23)

Let's see how this goes: https://github.com/web-platform-tests/wpt/pull/53444

This PR has now merged upstream, so once that is sync'd back to our tree, I think it should be possible to proceed with disabling the local Ahem installation.

There were issues reported by Chrome in their own CI and they requested a backout of the PR via https://github.com/web-platform-tests/wpt/pull/53716. But so far no further reply from their side. So maybe we should still wait a bit before continuing on this bug?

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

Eventually we might want to completely remove the font-installation code, but for now I suggest just changing the default we use. The above patch gives me very much quicker ./mach wpt startup locally, and tryserver logs show that we're passing --no-install-fonts so I assume it's working there as well.

Pushed by hskupin@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f06785e28c19 https://hg.mozilla.org/integration/autoland/rev/87dee2be361f Default to not installing fonts (Ahem.ttf) when we run web-platform-tests. r=jgraham,whimboo

I filed bug 1977796 as follow-up to get the font installation (uninstallation) code removed.

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/53810 for changes under testing/web-platform/tests
Blocks: 1977858
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/ca3473633546 https://hg.mozilla.org/integration/autoland/rev/88a182ceaa21 Revert "Bug 1965482 - Default to not installing fonts (Ahem.ttf) when we run web-platform-tests. r=jgraham,whimboo" for causing wpt failures in ahem.html.

Reverted this because it was causing wpt failures in ahem.html.

Flags: needinfo?(jfkthame)
Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a7cb19019f5f https://hg.mozilla.org/integration/autoland/rev/cdb57c81f444 Default to not installing fonts (Ahem.ttf) when we run web-platform-tests. r=jgraham,whimboo
Upstream PR merged by moz-wptsync-bot
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: