fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
534 stars 99 forks source link

Multithreading causes errors #4638

Closed dscorbett closed 2 months ago

dscorbett commented 2 months ago

Observed behavior

Running Font Bakery 0.12.0 with multithreading often causes errors. The errors do not always happen. Attested errors include:

com.google.fonts/check/layout_valid_feature_tags: Failed with AttributeError: FeatureList ``` ERROR Failed with AttributeError: FeatureList File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checkrunner.py", line 213, in _run_check subresults = list(subresults) ^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/layout.py", line 43, in com_google_fonts_check_layout_valid_feature_tags for tag in feature_tags(ttFont): ^^^^^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/layout.py", line 11, in feature_tags if ttFont.get(table) and ttFont[table].table.FeatureList: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontTools/ttLib/tables/otBase.py", line 893, in __getattr__ raise AttributeError(attr) ``` [code: failed-check] ```
com.google.fonts/check/layout_valid_script_tags: Failed with AttributeError: ScriptList ``` ERROR Failed with AttributeError: ScriptList File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checkrunner.py", line 213, in _run_check subresults = list(subresults) ^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/layout.py", line 77, in com_google_fonts_check_layout_valid_script_tags for tag in script_tags(ttFont): ^^^^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/layout.py", line 58, in script_tags if ttFont.get(table) and ttFont[table].table.ScriptList: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontTools/ttLib/tables/otBase.py", line 893, in __getattr__ raise AttributeError(attr) ``` [code: failed-check] ```
com.google.fonts/check/outline_alignment_miss: list index out of range ``` ERROR list index out of range [code: error] ```
com.google.fonts/check/xavgcharwidth: Failed with AttributeError: 'table__h_m_t_x' object has no attribute 'metrics' ``` ERROR Failed with AttributeError: 'table__h_m_t_x' object has no attribute 'metrics' File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checkrunner.py", line 213, in _run_check subresults = list(subresults) ^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/os2.py", line 77, in com_google_fonts_check_xavgcharwidth if not ttFont["hmtx"].metrics: # May contain just '.notdef', which is valid. ^^^^^^^^^^^^^^^^^^^^^^ ``` [code: failed-check] ```
com.google.fonts/check/xavgcharwidth: Failed with ZeroDivisionError: division by zero ``` ERROR Failed with ZeroDivisionError: division by zero File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checkrunner.py", line 213, in _run_check subresults = list(subresults) ^^^^^^^^^^^^^^^^ File "/Users/dcorbett/fb-errors/venv/lib/python3.12/site-packages/fontbakery/checks/opentype/os2.py", line 95, in com_google_fonts_check_xavgcharwidth expected_value = int(round(width_sum / count)) ~~~~~~~~~~^~~~~~~ ``` [code: failed-check] ```

Expected behavior

Multithreading should not cause errors.

Resources and steps needed to reproduce

curl -LO https://github.com/notofonts/latin-greek-cyrillic/releases/download/NotoSans-v2.013/NotoSans-v2.013.zip
unzip NotoSans-v2.013.zip
pip install 'fontbakery[notofonts]==0.12.0'
fontbakery check-notofonts -j NotoSans/unhinted/otf/NotoSans-Regular.otf
belluzj commented 2 months ago

I also observed this error, running with --auto-jobs has the problems, without --auto-jobs runs fine.

dscorbett commented 2 months ago

Another part of the problem is that git_rootdir temporarily changes the working directory, so checks that depend on the fonts’ paths can fail if the fonts are specified with relative paths. Instead of changing the working directory, it should use git -C.

felipesanches commented 2 months ago

thanks, @belluzj!