[MGNLIMG-219] Some tests fail on MacOS + latest JDK/OpenJDK 8 Created: 18/May/20  Updated: 18/Oct/22  Resolved: 22/Mar/22

Status: Closed
Project: Imaging
Component/s: None
Affects Version/s: 3.5.2
Fix Version/s: 3.5.3

Type: Bug Priority: Neutral
Reporter: Federico Grilli Assignee: Jesus Alonso
Resolution: Fixed Votes: 0
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

MacOS 10.14.6
jdk1.8.0_251 and openjdk 1.8.0_252
maven 3.6.3


Issue Links:
Cloners
is cloned by MGNLIMG-254 Some tests fail on MacOS + latest JDK... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Date of First Response:
Epic Link: AuthorX Maintenance
Sprint: AuthorX 5
Story Points: 2

 Description   

Tests were temporarily ignored. See https://git.magnolia-cms.com/projects/MODULES/repos/imaging/commits/59cdd1e5179cdbea5743955a300e07e4807fb51d

  • This started while releasing imaging 3.4.3 from my MacBook with MacOS 10.14.6
  • Tried with jdk1.8.0_251 and openjdk 1.8.0_252
  • Works locally with jdk1.8.0_25 (but release failed with an issue related to SSL and certificates when connecting to Nexus)
  • Also works fine on Jenkins (Linux) with jdk1.8.0_152
  • I suspect the issue is Mac OS specific and needs further investigation


 Comments   
Comment by Maxime Michel [ 27/Sep/21 ]

I could verify this on my local machine as well.

Comment by Maxime Michel [ 31/Jan/22 ]

ilgun could you please take this over in your domain team's backlog? We don't have any particular expertise to figure this out, nor resources to be honest. Thanks.

Comment by Ilgun Ilgun [ 31/Jan/22 ]

Thanks, mmichel. I'll ping ldelnevo for that. I think we haven't even included imaging in our domain filter yet.

Comment by Jesus Alonso [ 22/Mar/22 ]

This is the outcome after investigating this issue:

 [ERROR] info.magnolia.imaging.operations.cropresize.BoundedResizeTest.smallImageIsEnlargedWhileExpandTrue Time elapsed: 0.009 s <<< ERROR! java.lang.IllegalStateException: Can't find ImageWriter for jpeg

The error is happening because JPEGImageWriterSpi returns false in canEncodeImage. So the writer that handles the jpeg cannot process this particular image.
Using the exact same image but exported to jpg, all works ok.
The difference between using the png and the jpeg input image is

final ImageTypeSpecifier imgType = ImageTypeSpecifier.createFromRenderedImage(img);
  • for the png we have -> ColorModel: #pixelBits = 32 numComponents = 4 color space = java.awt.color.ICC_ColorSpace@314b8f2d transparency = 3 has alpha = true isAlphaPre = false
  • for the jpg (the new one) -> ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@669513d8 transparency = 1 has alpha = false isAlphaPre = false. So it looks like jpeg doesn’t handle the alpha channel correctly.

Changing the code to:

final ImageTypeSpecifier imgType = ImageTypeSpecifier.createFromRenderedImage(img);
final Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpeg");

the error we now have is:

javax.imageio.IIOException: Bogus input colorspace

	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native Method)
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeOnThread(JPEGImageWriter.java:1007)
	at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:371)
	at com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:162)

which seems to be related with transparency. And as we saw in the 2 images, png has transparency = 3 while jpg has transparency = 1.

All in all, it seems some versions of Java for MacOS does not handle transparency well.

Comment by Jesus Alonso [ 22/Mar/22 ]

Finally we have used the assumption API to exclude those failing tests when the build is in macOS

Generated at Mon Feb 12 02:13:27 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.