Skip to content

8154846: SwingNode does not resize when content size constraints are changed #15960

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

Closed
wants to merge 4 commits into from

Conversation

prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Sep 28, 2023

SwingNode does not update its internal cache of Swing pref/max/min height and widths when its JComponent content's corresponding size constraints are updated. As such, it isn't resized to honor those size constraints.

JLightweightFrame does install a PropertyChangeListener for "preferredSize", "maximumSize", and "minimumSize" properties, but this only happens via a ContainerListener which is not added until after the content has already been added to the content pane, and since the application cannot call this methods directly as per the documentation for the SwingNode.resize() method: Applications should not invoke this method directly. If an application needs to directly set the size of the SwingNode, it should set the Swing component's minimum/preferred/maximum size constraints which will be propagated correspondingly to the SwingNode and it's parent will honor those settings during layout.

so the fix is to add the listener as soon as the component is added to the JLightweightFrame's content.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8154846: SwingNode does not resize when content size constraints are changed (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15960/head:pull/15960
$ git checkout pull/15960

Update a local copy of the PR:
$ git checkout pull/15960
$ git pull https://git.openjdk.org/jdk.git pull/15960/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15960

View PR using the GUI difftool:
$ git pr show -t 15960

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15960.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 28, 2023

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 28, 2023
@openjdk
Copy link

openjdk bot commented Sep 28, 2023

@prsadhuk The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Sep 28, 2023
@mlbridge
Copy link

mlbridge bot commented Sep 28, 2023

Webrevs

@prsadhuk
Copy link
Contributor Author

/label add fx

@openjdk
Copy link

openjdk bot commented Sep 28, 2023

@prsadhuk
The label fx is not a valid label.
These labels are valid:

  • graal
  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@prsadhuk
Copy link
Contributor Author

prsadhuk commented Oct 4, 2023

Fix is updated to register listener before component is added/removed.

@andy-goryachev-oracle @aghaisas Can you please review this FX fix?

There is some SwingNode rendering issue still due to JDK-8298796 but size update issue should be fixed..

@andy-goryachev-oracle
Copy link

@prsadhuk
Pre-submit tests - windows-x64 / build - Build / test Failing after 75m — 1/2 failed

@prsadhuk
Copy link
Contributor Author

prsadhuk commented Oct 5, 2023

@prsadhuk Pre-submit tests - windows-x64 / build - Build / test Failing after 75m — 1/2 failed

Not sure on this..The failure says which has nothing to do with the change..

 Output from failing command(s) repeated here ===
* For target jdk_modules_java.management.rmi__the.java.management.rmi_batch:
IOException caught during compilation: Connection reset

@andy-goryachev-oracle
Copy link

could you restart the failing build? Let's make sure it's a transient build issue.

@andy-goryachev-oracle
Copy link

While running the SCCE in the ticket with the jdk compiled with the fix from pull/15960 on macOS 13.5.2 M1, noticed two things:

  1. the very first time it works as expected. There is a bit of flicker when the button gets replaced, perhaps it's due to runLater and invokeLater and debug output to stdout.
  2. subsequent runs exhibit a strange behavior where the button is not positioned at the center. Sometimes it's at the corner, and one time it was nowhere to be seen (the whole window was red). Example:
Screenshot 2023-10-05 at 11 59 14
  1. when clicking the button to make the size exceed the window size, I've got OOME. Perhaps it's expected:
Button size: java.awt.Dimension[width=3296,height=928]
SwingNode size: 3296.0 928.0
Button size: java.awt.Dimension[width=6592,height=1856]
SwingNode size: 6592.0 1856.0
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
	at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:76)
	at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
	at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
	at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:351)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.createImage(AquaPainter.java:193)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.lambda$paintFromSingleCachedImage$0(AquaPainter.java:178)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter$$Lambda/0x00000007702d7020.apply(Unknown Source)
	at java.desktop/sun.awt.image.MultiResolutionCachedImage.getResolutionVariant(MultiResolutionCachedImage.java:84)
	at java.desktop/sun.java2d.SunGraphics2D.getResolutionVariant(SunGraphics2D.java:3305)
	at java.desktop/sun.java2d.SunGraphics2D.drawHiDPIImage(SunGraphics2D.java:3133)
	at java.desktop/sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3371)
	at java.desktop/sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3321)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.paintFromSingleCachedImage(AquaPainter.java:186)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.paint(AquaPainter.java:141)
	at java.desktop/com.apple.laf.AquaPainter.paint(AquaPainter.java:90)
	at java.desktop/com.apple.laf.AquaButtonBorder.doButtonPaint(AquaButtonBorder.java:104)
	at java.desktop/com.apple.laf.AquaButtonBorder$Dynamic.doButtonPaint(AquaButtonBorder.java:241)
	at java.desktop/com.apple.laf.AquaButtonBorder.paintButton(AquaButtonBorder.java:100)
	at java.desktop/com.apple.laf.AquaButtonUI.paint(AquaButtonUI.java:316)
	at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
	at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:852)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1128)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:961)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1137)
	at java.desktop/sun.swing.JLightweightFrame$3.paint(JLightweightFrame.java:343)
	at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5318)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1656)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1631)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1569)
	at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1336)
	at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5266)
	at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5076)
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
	at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:76)
	at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
	at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
	at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:351)
	at java.desktop/sun.swing.JLightweightFrame.resizeBuffer(JLightweightFrame.java:458)
	at java.desktop/sun.swing.JLightweightFrame.reshape(JLightweightFrame.java:443)
	at java.desktop/java.awt.Component.setBounds(Component.java:2339)
	at java.desktop/java.awt.Window.setBounds(Window.java:3560)
	at jdk.unsupported.desktop/jdk.swing.interop.LightweightFrameWrapper.setBounds(LightweightFrameWrapper.java:110)
	at javafx.swing/com.sun.javafx.embed.swing.newimpl.SwingNodeInteropN.setBounds(SwingNodeInteropN.java:160)
	at javafx.swing/javafx.embed.swing.SwingNode.lambda$20(SwingNode.java:707)
	at javafx.swing/javafx.embed.swing.SwingNode$$Lambda/0x0000000770234888.run(Unknown Source)
	at javafx.swing/com.sun.javafx.embed.swing.SwingNodeHelper.runOnEDT(SwingNodeHelper.java:170)
	at javafx.swing/javafx.embed.swing.SwingNode.locateLwFrame(SwingNode.java:704)
	at javafx.swing/javafx.embed.swing.SwingNode.lambda$17(SwingNode.java:486)
	at javafx.swing/javafx.embed.swing.SwingNode$$Lambda/0x0000000770234ee8.run(Unknown Source)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.executePrivileged(AccessController.java:778)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
	at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:76)
	at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
	at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
	at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:351)
	at java.desktop/sun.swing.JLightweightFrame.resizeBuffer(JLightweightFrame.java:458)
	at java.desktop/sun.swing.JLightweightFrame.reshape(JLightweightFrame.java:443)
	at java.desktop/java.awt.Component.setBounds(Component.java:2339)
	at java.desktop/java.awt.Window.setBounds(Window.java:3560)
	at jdk.unsupported.desktop/jdk.swing.interop.LightweightFrameWrapper.setBounds(LightweightFrameWrapper.java:110)
	at javafx.swing/com.sun.javafx.embed.swing.newimpl.SwingNodeInteropN.setBounds(SwingNodeInteropN.java:160)
	at javafx.swing/javafx.embed.swing.SwingNode.lambda$20(SwingNode.java:707)
	at javafx.swing/javafx.embed.swing.SwingNode$$Lambda/0x0000000770234888.run(Unknown Source)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
	at java.base/java.security.AccessController.executePrivileged(AccessController.java:778)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
	at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:76)
	at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
	at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
	at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:351)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.createImage(AquaPainter.java:193)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.lambda$paintFromSingleCachedImage$0(AquaPainter.java:178)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter$$Lambda/0x00000007702d7020.apply(Unknown Source)
	at java.desktop/sun.awt.image.MultiResolutionCachedImage.getResolutionVariant(MultiResolutionCachedImage.java:84)
	at java.desktop/sun.java2d.SunGraphics2D.getResolutionVariant(SunGraphics2D.java:3305)
	at java.desktop/sun.java2d.SunGraphics2D.drawHiDPIImage(SunGraphics2D.java:3133)
	at java.desktop/sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3371)
	at java.desktop/sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3321)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.paintFromSingleCachedImage(AquaPainter.java:186)
	at java.desktop/com.apple.laf.AquaPainter$AquaSingleImagePainter.paint(AquaPainter.java:141)
	at java.desktop/com.apple.laf.AquaPainter.paint(AquaPainter.java:90)
	at java.desktop/com.apple.laf.AquaButtonBorder.doButtonPaint(AquaButtonBorder.java:104)
	at java.desktop/com.apple.laf.AquaButtonBorder$Dynamic.doButtonPaint(AquaButtonBorder.java:241)
	at java.desktop/com.apple.laf.AquaButtonBorder.paintButton(AquaButtonBorder.java:100)
	at java.desktop/com.apple.laf.AquaButtonUI.paint(AquaButtonUI.java:316)
	at java.desktop/javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
	at java.desktop/javax.swing.JComponent.paintComponent(JComponent.java:852)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1128)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:961)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1137)
	at java.desktop/sun.swing.JLightweightFrame$3.paint(JLightweightFrame.java:343)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:961)
	at java.desktop/javax.swing.JComponent.paint(JComponent.java:1137)
	at java.desktop/javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
	at java.desktop/javax.swing.JComponent.paintChildren(JComponent.java:961)
	at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5325)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(RepaintManager.java:1656)
	at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1631)
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

@andy-goryachev-oracle
Copy link

I think OOME is expected. The earlier stack trace was for retina (scale=2), when displaying on a secondary monitor with the scale=1 I am getting OOME later:

Button size: java.awt.Dimension[width=13184,height=3712]
SwingNode size: 13184.0 3712.0
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space

~48M * 4 bytes (I assume) = 193Mbytes.

@andy-goryachev-oracle
Copy link

What puzzles me is that I am getting inconsistent results.
Run the test, see the button, clicked once - the button disappears. Moved the window to another sceen - the button appears in the corner. Clicked on the button - now I see two buttons (corrupted screen buffer)?

Of course, I might be doing something wrong. My command line:

/Users/angorya/Projects/jdk/build/macosx-aarch64-client-release/jdk/bin/java -XX:+ShowCodeDetailsInExceptionMessages -ea -Djava.library.path=/Users/angorya/Projects/jfx3/jfx/rt/build/sdk/lib -Dfile.encoding=UTF-8 -p /Users/angorya/Projects/Test3/Test/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.base/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.controls/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.graphics/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.fxml/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.media/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.swing/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.web/bin -classpath /Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-api_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-migrationsupport_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-params_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-launcher_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-runner_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-api_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-vintage-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.opentest4j_1.2.0.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.apiguardian.api_1.1.2.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.junit_4.13.2.v20211018-1956.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --add-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.fxml=javafx.controls --add-exports javafx.base/com.sun.javafx.collections=javafx.fxml --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --add-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.base/com.sun.javafx=javafx.web --add-exports javafx.base/test.util.memory=javafx.web --add-reads javafx.web=java.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management -m andy_test/goryachev.apps.AppTestLauncher

Screenshot 2023-10-05 at 12 13 45

@prsadhuk
Copy link
Contributor Author

prsadhuk commented Oct 6, 2023

What puzzles me is that I am getting inconsistent results. Run the test, see the button, clicked once - the button disappears. Moved the window to another sceen - the button appears in the corner. Clicked on the button - now I see two buttons (corrupted screen buffer)?

Of course, I might be doing something wrong. My command line:

/Users/angorya/Projects/jdk/build/macosx-aarch64-client-release/jdk/bin/java -XX:+ShowCodeDetailsInExceptionMessages -ea -Djava.library.path=/Users/angorya/Projects/jfx3/jfx/rt/build/sdk/lib -Dfile.encoding=UTF-8 -p /Users/angorya/Projects/Test3/Test/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.base/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.controls/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.graphics/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.fxml/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.media/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.swing/bin:/Users/angorya/Projects/jfx3/jfx/rt/modules/javafx.web/bin -classpath /Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-api_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-migrationsupport_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-jupiter-params_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-launcher_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-runner_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-api_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-engine_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-platform-suite-commons_1.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/junit-vintage-engine_5.9.3.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.opentest4j_1.2.0.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.apiguardian.api_1.1.2.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.junit_4.13.2.v20211018-1956.jar:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.hamcrest.core_1.3.0.v20180420-1519.jar --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --add-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-reads javafx.fxml=javafx.controls --add-exports javafx.base/com.sun.javafx.collections=javafx.fxml --add-exports javafx.graphics/test.com.sun.javafx.pgstub=javafx.controls --add-exports javafx.base/test.com.sun.javafx.binding=javafx.controls --add-exports javafx.base/test.util.memory=javafx.controls --add-exports javafx.base/test.javafx.collections=javafx.controls --add-exports javafx.base/com.sun.javafx.property=javafx.graphics --add-exports javafx.base/test.util.memory=javafx.graphics --add-exports java.base/sun.security.util=javafx.graphics --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management --add-exports javafx.base/com.sun.javafx=javafx.web --add-exports javafx.base/test.util.memory=javafx.web --add-reads javafx.web=java.management --add-reads javafx.base=java.management --add-reads javafx.base=jdk.management -m andy_test/goryachev.apps.AppTestLauncher

Screenshot 2023-10-05 at 12 13 45

Button appearing at the corner issue existed before the fix also as I see in this screenshot... (SInce the size was not updated before the fix, the label was truncated but it is moved to the corner as you can see)

image

disappear and reappear issue seems to be due to JDK-8298796 SwingNode rendering issue as I mentioned earlier in this PR...so I think we can ignore the unsolved rendering issue for now and see it as size update fix (although it may alleviate rendering issue to the user but maybe one fix at a time)

I normally test with this command
./jdk/bin/java @e://ade//javafx//jfx//rt//build//run.args SwingNodeResize

where run.args is
--module-path="E:/ade/javafx/jfx/rt/build/sdk/lib"
--add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web

@andy-goryachev-oracle
Copy link

Pre-submit tests - linux-x64 / test - Test (tier1) Failing after 80m — 1/10 failed
(❌ linux-x64 / test (hs/tier1 serviceability))
why is that?

@andy-goryachev-oracle
Copy link

With the latest change, it behaves as expected on the primary retina screen.

However, something is wrong if I put it on the secondary monitor right after the launch: I am still getting inconsistent behavior, incorrect button location, and visual artifacts.

For example, one time there is no button after the first click. The button appears when I resize the window.

Another time, the button is in the corner again and some visual artifacts are present (see the screenshots below).

Perhaps we need to update the scale somewhere?

Screenshot 2023-10-06 at 10 28 26

Screenshot 2023-10-06 at 10 28 34

@andy-goryachev-oracle
Copy link

just in case, my monitor setup:

Screenshot 2023-10-06 at 10 35 33

@prsadhuk
Copy link
Contributor Author

prsadhuk commented Oct 9, 2023

With the latest change, it behaves as expected on the primary retina screen.

However, something is wrong if I put it on the secondary monitor right after the launch: I am still getting inconsistent behavior, incorrect button location, and visual artifacts.

For example, one time there is no button after the first click. The button appears when I resize the window.

Another time, the button is in the corner again and some visual artifacts are present (see the screenshots below).

Perhaps we need to update the scale somewhere?

I am not able to reproduce these issues (apart from JDK-8298796) in windows primary and secondary monitor (primary 1.25 1920x1080, secondary 1.0 1920x1080, doesn't have FX setup in mac to test ...Also, I dont see how window can be painted red as the test doesn't do that so how did you get RED background)

I think you are seeing the scale issue what you already mentioned in here
openjdk/jfx#1171 (comment)
and Kevin mentioned openjdk/jfx#1171 (comment) and openjdk/jfx#1171 (review)
so I guess it's an existing issue in mac and not something that this fix has caused and since you confirmed this works on primary screen, can we push this and you can raise a macos FX bug regarding scale not being propagated to window (which might require change in non swing-interop FX code)

@andy-goryachev-oracle
Copy link

let me test this on windows.

in the mean time, do you know why the checks are consistently failing for this PR?

@prsadhuk
Copy link
Contributor Author

in the mean time, do you know why the checks are consistently failing for this PR?

No, this failure is in hotspot and it's ok to ignore this....nothing to do with the change in this PR
linux-x64 / test (hs/tier1 serviceability)

@prsadhuk
Copy link
Contributor Author

in the mean time, do you know why the checks are consistently failing for this PR?

No, this failure is in hotspot and it's ok to ignore this....nothing to do with the change in this PR ❌ linux-x64 / test (hs/tier1 serviceability)

These actions seems to fail one or the other which does not seem to affect integration...for ex. #16068 another action fail....many of earlier PRs also has one or more failure in these actions but never fail build/test after integration..

@andy-goryachev-oracle
Copy link

@prsadhuk could you please point me to a pre-built jdk with your fix? I am getting build errors - maybe because of git's autocrlf, but it's going to take too much time for me trying to resolve the issue. If I could download something already built it would be much easier. thanks!

Copy link
Contributor

@prrace prrace left a comment

Choose a reason for hiding this comment

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

So basically the code is out of order. A container listener is added which installs the property listeners but its all too late.
The content was already added so the event is missed. The fix is simply to move the block that adds the content to
after the listener is installed. Seems OK to me, but @kevinrushforth should test this.

@prrace
Copy link
Contributor

prrace commented Oct 10, 2023

/reviewers 2

@openjdk
Copy link

openjdk bot commented Oct 10, 2023

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8154846: SwingNode does not resize when content size constraints are changed

Reviewed-by: prr, angorya, arapte

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 401 new commits pushed to the master branch:

  • 4ea1b99: 8317262: LockStack::contains(oop) fails "assert(t->is_Java_thread()) failed: incorrect cast to JavaThread"
  • 01ea1ef: 8305971: NPE in JavacProcessingEnvironment for missing enum constructor body
  • 1d54e73: 8318072: DowncallLinker does not acquire/release segments in interpreter
  • 56aa1e8: 8317683: Add JIT memory statistics
  • f7d6d7a: 8266242: java/awt/GraphicsDevice/CheckDisplayModes.java failing on macOS 11 ARM
  • e942f36: 8317535: Shenandoah: Remove unused code
  • 7cb2e6d: 8317514: Ensure MemorySegment is initialized before touching NativeMemorySegmentImpl
  • 9622de2: 8317372: Refactor some NumberFormat tests to use JUnit
  • 72c4dcb: 8317970: Bump target macosx-x64 version to 11.00.00
  • 32a60cf: 8317824: Beef up javadoc for base offset in var handles derived from layouts (mainline)
  • ... and 391 more: https://git.openjdk.org/jdk/compare/8f4dfc443ba5820f5799fff1418d6632d502d57b...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 10, 2023
@openjdk
Copy link

openjdk bot commented Oct 10, 2023

@prrace
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 10, 2023
@prsadhuk
Copy link
Contributor Author

@prsadhuk could you please point me to a pre-built jdk with your fix? I am getting build errors - maybe because of git's autocrlf, but it's going to take too much time for me trying to resolve the issue. If I could download something already built it would be much easier. thanks!

I have DM-ed you the pre-build jdk path

@andy-goryachev-oracle
Copy link

so tested on windows 11 with your pre-built jdk and the latest fx master branch.

What I see is some kind of behavior that happens when the code is missing repaint() and/or validate(). When the window comes up first, it looks like this - with the button not painted (a solid black block):

Screenshot 2023-10-12 092011

a mouse over repaints the button (possibly due to hover?), or window resizing repaints the button.

When I then click on the button, I see either 1/4 of the larger button where it is supposed to be, or at the corner, like so:
Screenshot 2023-10-12 092024

resizing a window slightly places the button in the right spot and removes all the artifacts.

All this happens on the primary screen with a 100% scale.

@prsadhuk
Copy link
Contributor Author

so tested on windows 11 with your pre-built jdk and the latest fx master branch.

What I see is some kind of behavior that happens when the code is missing repaint() and/or validate(). When the window comes up first, it looks like this - with the button not painted (a solid black block):

Screenshot 2023-10-12 092011

a mouse over repaints the button (possibly due to hover?), or window resizing repaints the button.

When I then click on the button, I see either 1/4 of the larger button where it is supposed to be, or at the corner, like so: Screenshot 2023-10-12 092024

resizing a window slightly places the button in the right spot and removes all the artifacts.

All this happens on the primary screen with a 100% scale.

Yes, known issue...please refer JDK-8298796

@andy-goryachev-oracle
Copy link

Testing this on a secondary screen with a 175% scale: the button is painted, works right most of the time, but occasionally the button is not placed at the center, or is 1/4 painted, or disappears completely (until I resize the window). So, basically, it exhibits the same symptoms as on the primary screen. It is very inconsistent, the results vary between launches.

Screenshot 2023-10-12 093109

@andy-goryachev-oracle
Copy link

Screenshot 2023-10-12 093604

@andy-goryachev-oracle
Copy link

just for fun, added

                    button.getParent().validate();
                    button.getParent().repaint();

after button.setSize(buttonSize); with not much effect. Which makes me think the problem might be in the way the swing damage gets propagated to fx maybe?

@prsadhuk
Copy link
Contributor Author

Yes, known issue...please refer JDK-8298796

As already mentioned above, this are known issues and not caused by this PR..
This issues will be investigated as part of that JBS...

@andy-goryachev-oracle
Copy link

yes; i can see how JDK-8298796 might affect the initial state, but the issue seems to go beyond initial state. updating the preferred size is not working reliably - so perhaps it is JDK-8298796 or perhaps it is some other issue?

Copy link

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

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

Assuming the issue we are seeing are due to JDK-8298796, the code changes look good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 16, 2023
@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 16, 2023

Going to push as commit 37eb986.
Since your change was applied there have been 405 commits pushed to the master branch:

  • 37aed6f: 8315362: NMT: summary diff reports threads count incorrectly
  • 1e930db: 8316585: [REDO] runtime/InvocationTests spend a lot of time on dependency verification
  • 0275efa: 8316304: (fs) Add support for BasicFileAttributes.creationTime() for Linux
  • 77d40ce: 8318085: ProblemList jdk/jfr/api/consumer/recordingstream/TestOnEvent.java on linux-aarch64
  • 4ea1b99: 8317262: LockStack::contains(oop) fails "assert(t->is_Java_thread()) failed: incorrect cast to JavaThread"
  • 01ea1ef: 8305971: NPE in JavacProcessingEnvironment for missing enum constructor body
  • 1d54e73: 8318072: DowncallLinker does not acquire/release segments in interpreter
  • 56aa1e8: 8317683: Add JIT memory statistics
  • f7d6d7a: 8266242: java/awt/GraphicsDevice/CheckDisplayModes.java failing on macOS 11 ARM
  • e942f36: 8317535: Shenandoah: Remove unused code
  • ... and 395 more: https://git.openjdk.org/jdk/compare/8f4dfc443ba5820f5799fff1418d6632d502d57b...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 16, 2023
@openjdk openjdk bot closed this Oct 16, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 16, 2023
@openjdk
Copy link

openjdk bot commented Oct 16, 2023

@prsadhuk Pushed as commit 37eb986.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@prsadhuk prsadhuk deleted the JDK-8154846 branch October 16, 2023 09:04
@prsadhuk prsadhuk restored the JDK-8154846 branch October 16, 2023 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants