eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

Incorrect Swing GUI behaviour on Mac AArch64 #17393

Closed 0xdaryl closed 1 year ago

0xdaryl commented 1 year ago

There is an issue running a Swing-based application on native macOS AArch64. Menus and dialog boxes repaint as white and do not refresh, and hangs are sometimes observed.

I have not seen this behave incorrectly when run with -Xint.

To reproduce:

1) Reproduce with a 17.0.6 Semeru build:

https://github.com/ibmruntimes/semeru17-binaries/releases/download/jdk-17.0.6%2B10_openj9-0.36.0/ibm-semeru-open-jdk_aarch64_mac_17.0.6_10_openj9-0.36.0.tar.gz

2) Download IBM Thread and Monitor Dump Analyzer

See link at the "Download the jar" step here -> https://www.ibm.com/support/pages/ibm-thread-and-monitor-dump-analyzer-java-tmda

A problem like this was reported on two Swing-based applications, but the TMDA application is one that is easy to get and reproduce with.

3) java -jar jca4614.jar

4) When the application starts, play around with the GUI a bit: open menus, click boxes, drag windows, etc. You could even load a javacore into the analyzer as well. In about 10-15 seconds the bad behaviour should be seen.

0xdaryl commented 1 year ago

Reproducible with -Xshareclasses:none -Xjit:optlevel=cold. Not seen with noopt.

0xdaryl commented 1 year ago

One of the problematic methods appears to be:

sun/java2d/opengl/OGLTextureToSurfaceBlit.Blit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Lsun/java2d/pipe/Region;IIIIII)V

I suspect this problem appears in other methods as well because excluding just this one method does not avoid the problem. However, running with only this method compiled will reproduce the problem.

0xdaryl commented 1 year ago

This appears to be a codegen bug passing one of the in-memory arguments on a method dispatch sequence to:

sun/java2d/opengl/OGLBlitLoops.IsoBlit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/image/BufferedImage;Ljava/awt/image/BufferedImageOp;Ljava/awt/Composite;Lsun/java2d/pipe/Region;Ljava/awt/geom/AffineTransform;IIIIIDDDDZ)V

The argument is being clobbered during the dispatch sequence before being stored on the frame. Not sure why yet...

knn-k commented 1 year ago

I haven't looked into the generated code, but PR #16458 might have fixed this issue. The fix is not available in v0.36.

0xdaryl commented 1 year ago

Yes, the problem seemed familiar to me and I've been trying to get a build to run locally to verify that particular fix.

The problem is indeed because we're not copying one of the args into a temp.

0xdaryl commented 1 year ago

Not verified, but reviewing that PR again that is exactly the fix I would have implemented to fix this. But will confirm...

knn-k commented 1 year ago

I ran the application with the following binaries, and I observed the weird behavior with neither of them.

0xdaryl commented 1 year ago

This has been fixed in 0.38+ builds. The user confirms they no longer see the problem running a 0.38 build on their application either. Closing.