Problem/Motivation
The ToolkitGdTest test fails on PHP 8.5 probably because of
- https://github.com/php/php-src/pull/13443
- https://github.com/php/php-src/pull/18940
maybe related
- https://github.com/php/php-src/pull/17375
- https://github.com/php/php-src/pull/19107
Steps to reproduce
See the latest pipeline in https://git.drupalcode.org/project/drupal/-/merge_requests/12877/pipelines
https://git.drupalcode.org/issue/drupal-3523596/-/jobs/6224316
✘ Manipulations with 29
┐
├ Image 'image-test.gif' object after 'rotate_5' action has the correct color placement at corner '0' - Actual: {255,0,93,0}, Expected: {255,0,255,0}, Distance: 26244, Tolerance: 0
├ Failed asserting that 26244 is equal to 0 or is less than 0.
│
│ /builds/issue/drupal-3523596/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php:90
│ /builds/issue/drupal-3523596/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php:357
┴
✘ Manipulations with 30
┐
├ Image 'image-test.gif' object after 'rotate_transparent_5' action has the correct color placement at corner '0' - Actual: {255,93,0,46}, Expected: {255,255,255,127}, Distance: 97830, Tolerance: 0
├ Failed asserting that 97830 is equal to 0 or is less than 0.
│
│ /builds/issue/drupal-3523596/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php:90
│ /builds/issue/drupal-3523596/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php:357
┴Proposed resolution
find out why rotation failing and fix
get feedback from https://github.com/php/php-src/issues/20201
Remaining tasks
MR, review, commit
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | image-test.png_to_rotate_5_onPHP8.5.png | 782 bytes | mondrake |
| #34 | image-test.png_to_rotate_5_onPHP8.4.png | 759 bytes | mondrake |
Issue fork drupal-3540531
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3540531-fix-toolkitgdtest-for
changes, plain diff MR !13006
- 3540531-test-on-php-85
changes, plain diff MR !13007
Comments
Comment #2
andypostComment #3
andypostComment #7
andypostCreated testing branch with patches to run tests on 8.5 from #3523596: [meta] PHP 8.5 support
Comment #8
taran2lSo, my idea was to recreate the file itself (maybe it has encoding issues), but that didn't work ...
Comment #9
andypostThank you, looks like good idea but I think the rotation got changes(
Comment #10
andypostComment #11
taran2lSeems like rotation is affected either by our code or by how PHP8.5 handles it, as all rotate to 5 degrees tests are broken (file format is not relevant, it happens for all of them)
See https://git.drupalcode.org/issue/drupal-3540531/-/jobs/6225263#L2188
The other part is AVIF, I assume Docker image does not have AVIF support at all (or it's broken in PHP itself)
Comment #12
taran2lSo, it seems that the default interpolation algorithm has been changed, see https://github.com/php/php-src/pull/17375/files#diff-a6d1ba8e66261eacec5...
That probably means that we need to adjust test to that
Comment #14
andypostIIRC we fixed AVIF long time ago by using Ubuntu as a source for CI images
Comment #15
mondrakeThis is critical to support PHP 8.5.
Comment #17
taran2lSo, the GD issue with rotate was indeed related to the default interpolation method change (should core now keep the BC and set it explicitly?)
The AVIF issues is mystery, as it fails on loading the image rather than processing. Is AVIF part of the docker image?
And due to new deprecations (PDO constants) most of the tests are red
Comment #19
andypostI think BC layer should be added at least with condition
PHP_VERSION_ID < 80500AVIF should be working, it's added to CI images since PHP 8.1 so all images reports it\s supported, maybe needs better check but
Comment #20
andypostbtw runnign php's tests it reports no issues with AVIF, so probably something wrong in core's code or maybe we need to report something to php upstream
PS few more fixes for beta2 added in #3523596: [meta] PHP 8.5 support and the only failures left because of composer's dependecy which should be fixed later this week https://github.com/jsonrainbow/json-schema/pull/840
Comment #21
taran2lI think PHP has broken AVIF detection by introducing HEIF/HEIC support here https://github.com/php/php-src/commit/dfac2da7fba930570fcda99205cfcf53db...
Comment #22
taran2lThe problem is that HEIF image can ... pretend not not be HEIF, and ... be an AVIF
See https://github.com/nokiatech/heif/issues/74 for details
Our test image is like example C034.heic:
so it has
mif1andavif, but nohei*... but PHP detectsmif1first and decides that the file is a HEIF image, which it's not true in this caseComment #23
andypostThank you finding it, missed this change... btw curious how they added support without
libheif, cos they are not 100% compatible and very probablyubuntu:noblehas somehow outdated libavif.I will check what GD library (which is bundled into PHP) supports to link to as Ubuntu contains libavif16 - 1.0.4 but upstream is 1.3.0 and starting with 1.2.0 it has experimental support for HEIF under experimental flag
Comment #24
taran2lso, it does not support HEIF for processing, only for getting the image dimensions - and the code to do that is the same as avif:
and the reason for that is (I believe): both standards are basically use the same container format ... technically AVIF is an AV1 encoded image in HEIF container, while HEIC is an HEVC encoded image in HEIF container. Very confusing actually :D
Comment #25
andypostset of commits merged for heic so next release can help to move forward
ref https://github.com/php/php-src/commit/02c13b67bcf1eb122543ca4ba337499412...
Comment #26
andypostFiled upstream issue https://github.com/php/php-src/issues/20201
Comment #27
mondrakeAVIF images misdetected as HEIF after introducing HEIF support in getimagesize() was fixed upstream so in PHP 8.5RC4 we should not longer have that part to be solved.
What remains is the different default interpolation used in PHP 8.5 vs earlier versions.
This test is one of the longest running kernel tests, I think it would make sense to split it in an abstract base class and one concrete test class per image type (gif, png, webp, etc.).
It should not be that hard, will try to look into it.
Comment #28
mondrakeIMHO
should be placed in the toolkit code, conditionally on the PHP version, not in the test. Otherwise we'd be testing something that does not match the normal runtime behavior.
Or, we need to have different reference values to check against (again, PHP version-dependent).
Setting to NR for comments.
Comment #29
andypostupdated 8.5 image is pushed (contains fix for AVIF/HEIF)
Comment #30
mondrake#29 - thanks @andypost, AVIF now looks OK in latest tests.
#28 - In the end I think we should be testing conditionally on PHP version, without changing the default interpolation algo. Latest commit does that.
Comment #31
mondrakeAll the new Kernel tests (one per image type) are green on PHP 8.5 now.
Comment #32
andypostThank you! I think it ready to go and improving tests
PS: added MR's diff for testing and now only composer's tests fail https://git.drupalcode.org/issue/drupal-3523596/-/pipelines/645292
Comment #33
andypostsorry
Comment #34
mondrakeOut of curiosity, I checked out the rotated image derivatives from the CI runs, and they're actually quite different in PHP 8.4 and 8.5 (obviously, on the pixel level: you need to zoom in the image quite a lot to see a human perceivable difference). Attaching here.
This is an area where local testing may yield different results, as PHP with the embedded GD library (that Drupal GitLabCI uses) has code quite different from PHP that links the library separately, as #2921123: Adjust Rectangle class to calculate rotated image dimensions according to libgd 2.2.2+ shown extensively.
Comment #35
andypostis using bundled into
php-srcforked source oflibgdwhich is updated but other envs can try link to system library which usually very datedComment #36
taran2lNice to see it finally almost in.
Comment #37
alexpottCommitted and pushed 419838e7841 to 11.x and 99e7d471466 to 11.3.x. Thanks!