Skip to content
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

Avoid getting the GraalVM version at deployment time for AWT #43829

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

zakkak
Copy link
Contributor

@zakkak zakkak commented Oct 11, 2024

Reduces the times we start a container when using a builder-image

Copy link

quarkus-bot bot commented Oct 11, 2024

/cc @Karm (awt), @galderz (awt)

@Karm
Copy link
Member

Karm commented Oct 11, 2024

I'm sorry for the noise, I've just realized this is a draft. I'm gonna wait how it unfolds first.

Btw, testing with runtime container too, which is not a part of the regular GHA here, is a good thing to try with changes:

(locally Java 17)
$ ./mvnw verify -f integration-tests/pom.xml -pl awt -Ddocker -Dnative 
  -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true 
  -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 
  -Dquarkus.native.container-runtime=podman 2>&1 | tee log.log

@zakkak zakkak force-pushed the 2024-10-11-awt-processor-refactor branch 4 times, most recently from 2d575aa to 942c089 Compare October 14, 2024 11:57
@zakkak zakkak marked this pull request as ready for review October 14, 2024 20:40
@zakkak zakkak requested a review from Karm October 14, 2024 20:40

This comment has been minimized.

Comment on lines 12 to 23
if (JavaVersionUtil.isJava19OrHigher()) {
try {
RuntimeJNIAccess.register(Class.forName("sun.font.FontUtilities"));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: we are still supporting GraalVM/Mandrel for Java 17 in Quarkus 3.17+?

I thought we had all sorts of issues with it?

Copy link
Contributor Author

@zakkak zakkak Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't support it (as in we will probably not go to great extends to fix something not working there), but we also don't forbid Quarkus to use it, see #39866 and #43455. As long as it's not getting in the way we prefer to stay somewhat compatible with it for the time being.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. FWIW I'm in favor of dropping it whenever you feel comfortable.

@gsmet
Copy link
Member

gsmet commented Oct 17, 2024

@Karm any chance you could have a look at this one before next Tuesday? I'd let to get all these relatively closely related patches into 3.16 if possible.

@Karm
Copy link
Member

Karm commented Oct 17, 2024

@gsmet Yes, I'll do that. Bumping the priority.

@KarmBot
Copy link

KarmBot commented Oct 17, 2024

Adjusting priority for my human worker @Karm renice -n --16

Copy link
Member

@Karm Karm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @zakkak @gsmet,

False Negatives

I took a look and it seems that it's hard to verify any AWT related changes as the test have been disabled for some time. At least since this I guess?

image

One would assume that -DskipITs might control the failsafe, but it's not the case. Both in-container and hosted tests are skipped. The harness builds the native image but doesn't run any tests with it. In case of in-container tests, the harness builds the naitive-image, builds a container image and copies the executable in it, starts the container, but doesn't do any testing with it.

I had to manually change:

diff --git a/integration-tests/awt/pom.xml b/integration-tests/awt/pom.xml
index f71302da2c2..eb290a5e037 100644
--- a/integration-tests/awt/pom.xml
+++ b/integration-tests/awt/pom.xml
@@ -164,7 +164,7 @@
             <plugin>
                 <artifactId>maven-failsafe-plugin</artifactId>
                 <configuration>
-                    <skip>true</skip>
+                    <skip>false</skip>
                 </configuration>
             </plugin>
         </plugins>

This PR branch fails 🔴

To obtain results.
In case of this PR branch, HEAD 942c089, and host JDK 17.0.13 and Builder image version: Mandrel-23.1.4.0-Final (build 21.0.4+7-LTS) I got a failure that indicates that different images than expected were generated. Usual failure is that fonts weren't loaded so that's why pixels differ where text was supposed to be. I am yet to dump those images to take a look.

[ERROR] Failures: 
[ERROR]   ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 TIFF: Wrong pixel at 80x56. Expected: [46,14,32,255] Actual: [194,59,132,255] ==> expected: <true> but was: <false>
[ERROR]   ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 GIF: Wrong pixel at 80x56. Expected: [2,0,0,0] Actual: [156,0,0,0] ==> expected: <true> but was: <false>
[ERROR]   ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 PNG: Wrong pixel at 80x56. Expected: [46,14,32,255] Actual: [194,59,132,255] ==> expected: <true> but was: <false>
[ERROR]   ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 JPG: Wrong pixel at 80x56. Expected: [73,0,44,0] Actual: [201,53,137,0] ==> expected: <true> but was: <false>
[ERROR]   ImageGeometryFontsIT>ImageGeometryFontsTest.testGeometryAndFonts:89 BMP: Wrong pixel at 80x56. Expected: [46,14,32,0] Actual: [194,59,132,0] ==> expected: <true> but was: <false>
[INFO] 
[ERROR] Tests run: 41, Failures: 5, Errors: 0, Skipped: 0
[INFO] 

The failure is the same when I had the test run locally, with Mandrel installed locally (Mandrel-23.1.4.0-Final (build 21.0.4+7-LTS)).

Q 3.15.1 Passes 🟢

When I built & ran Quarkus 3.15.1
with the same change:

-                    <skip>true</skip>
+                    <skip>false</skip>

the test passes though. Mandrel-23.1.4.0-Final (build 21.0.4+7-LTS) both locally and as a builder-image. So I suspect it's really fonts and related to this change.


// Added for JDK 19+ due to: https://github.com/openjdk/jdk20/commit/9bc023220 calling FontUtilities
if (v.jdkVersionGreaterOrEqualTo("19")) {
classes.add("sun.font.FontUtilities");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zakkak So this is meant like a cleanup for JDK 21+ only , right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's moved to the new AwtFeature (https://github.com/quarkusio/quarkus/pull/43829/files#diff-086ee2e4b2043822961920521dd5be21c10c6805629f87f5b79d5836eb978e28R14).

The idea is to avoid version checks at Quarkus deployment phase (were we are still not sure what GraalVM version will be used).


// Added for JDK 19+ due to: https://github.com/openjdk/jdk20/commit/9bc023220 calling FontUtilities
if (v.jdkVersionGreaterOrEqualTo("19")) {
classes.add("sun.font.FontUtilities");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's moved to the new AwtFeature (https://github.com/quarkusio/quarkus/pull/43829/files#diff-086ee2e4b2043822961920521dd5be21c10c6805629f87f5b79d5836eb978e28R14).

The idea is to avoid version checks at Quarkus deployment phase (were we are still not sure what GraalVM version will be used).

Comment on lines -261 to -267
if (v.javaVersion.feature() != 19) {
classes.add("java.awt.GraphicsEnvironment");
classes.add("sun.awt.X11GraphicsConfig");
classes.add("sun.awt.X11GraphicsDevice");
classes.add("sun.java2d.SunGraphicsEnvironment");
classes.add("sun.java2d.xr.XRSurfaceData");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Karm these are cleanup, as we no longer support JDK 19, so I always include these classes

@zakkak zakkak force-pushed the 2024-10-11-awt-processor-refactor branch 2 times, most recently from 804d230 to fddb6d2 Compare October 21, 2024 10:46
@Karm
Copy link
Member

Karm commented Oct 21, 2024

fddb6d2 still fails for me.

@zakkak zakkak force-pushed the 2024-10-11-awt-processor-refactor branch from fddb6d2 to b95789b Compare October 21, 2024 11:46
@zakkak
Copy link
Contributor Author

zakkak commented Oct 21, 2024

fddb6d2 still fails for me.

I managed to reproduce (and fix) the issue. PTAL when you can.

@Karm
Copy link
Member

Karm commented Oct 21, 2024

fddb6d2 still fails for me.

I managed to reproduce (and fix) the issue. PTAL when you can.

WIP...

@Karm Karm self-requested a review October 21, 2024 14:54
Copy link
Member

@Karm Karm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, with the change at b95789b I can say that the test passes with:

  • JDK 17.0.13 and native-image in builder image Mandrel-23.1.4.0-Final
  • JDK 17.0.13 and native-image locally Mandrel-23.1.5.0-Final (build 21.0.5+11-LTS)
  • both local and in-container testing is ok
  • it's also fine to have JDK 21 on both ends
  • JDK 17.0.13 and native-image Mandrel-24.1.1.0-Final (build 23.0.1+11) is ok.

What fails is the very latest early access JDK 24 and Mandrel master on fonts dir lookup:

Caused by: java.io.IOException: Problem reading font data.
    at java.desktop@24-beta/java.awt.Font.createFont0(Font.java:1205)
    at java.desktop@24-beta/java.awt.Font.createFont(Font.java:1076)
    at io.quarkus.awt.it.Application.init(Application.java:63)

it is unrelated to this PR though, it fails with 3.15.1 too. I need to port the substitution to the latest JDK.

THX @zakkak 🙏

@zakkak zakkak added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Oct 21, 2024

This comment has been minimized.

Copy link

quarkus-bot bot commented Oct 21, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit b95789b.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
JVM Tests - JDK 17 Build ⚠️ Check → Logs Raw logs 🚧
✔️ JVM Tests - JDK 21 Logs Raw logs 🚧

You can consult the Develocity build scans.

@zakkak
Copy link
Contributor Author

zakkak commented Oct 22, 2024

The mongodb failures seem unrelated.

@zakkak zakkak merged commit 031d580 into quarkusio:main Oct 22, 2024
52 of 53 checks passed
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Oct 22, 2024
@zakkak zakkak deleted the 2024-10-11-awt-processor-refactor branch October 22, 2024 07:52
@quarkus-bot quarkus-bot bot added this to the 3.17 - main milestone Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants