RFR: 8274932: Render scales in EmbeddedWindow are not properly updated

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Jul 7 16:46:03 UTC 2023


On Thu, 6 Jul 2023 13:10:44 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> When the JavaFX scene is set before it is really shown, then the scale factors are not properly propagated to the EmbeddedWindow, resulting in showing wrong scales.
> Fix is made to update scales to EmbeddedWindow

> Testing on Mac with 2 monitors (primary scale=2, secondary scale=1), running the Main class from the ticket.
> 
> 1. getting exception:
> 
> ```
> Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0
> 	at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:293)
> 	at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:475)
> 	at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:475)
> 	at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:116)
> 	at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:110)
> 	at javafx.controls/javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:282)
> 	at javafx.controls/javafx.scene.control.skin.LabeledSkinBase.lambda$11(LabeledSkinBase.java:219)
> 	at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$1(LambdaMultiplePropertyChangeListenerHandler.java:88)
> 	at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
> 	at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:192)
> 	at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91)
> 	at javafx.base/javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
> 	at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
> 	at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
> 	at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:1)
> 	at javafx.base/javafx.beans.property.StringProperty.setValue(StringProperty.java:71)
> 	at javafx.controls/javafx.scene.control.Labeled.setText(Labeled.java:147)
> 	at andy_test/goryachev.apps.EmbeddedFrameBug.updateText(EmbeddedFrameBug.java:86)
> 	at andy_test/goryachev.apps.EmbeddedFrameBug.lambda$3(EmbeddedFrameBug.java:69)
> 	at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:192)
> 	at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:91)
> 	at javafx.base/javafx.beans.property.DoublePropertyBase.fireValueChangedEvent(DoublePropertyBase.java:107)
> 	at javafx.base/javafx.beans.property.DoublePropertyBase.markInvalid(DoublePropertyBase.java:114)
> 	at javafx.base/javafx.beans.property.DoublePropertyBase.set(DoublePropertyBase.java:148)
> 	at javafx.graphics/javafx.stage.Window.setRenderScaleX(Window.java:494)
> 	at javafx.swing/javafx.embed.swing.JFXPanel.updateComponentSize(JFXPanel.java:640)
> 	at javafx.swing/javafx.embed.swing.JFXPanel.addNotify(JFXPanel.java:945)
> 	at java.desktop/java.awt.Container.addNotify(Container.java:2804)
> 	at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4846)
> 	at java.desktop/java.awt.Container.addNotify(Container.java:2804)
> 	at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4846)
> 	at java.desktop/java.awt.Container.addNotify(Container.java:2804)
> 	at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4846)
> 	at java.desktop/javax.swing.JRootPane.addNotify(JRootPane.java:721)
> 	at java.desktop/java.awt.Container.addNotify(Container.java:2804)
> 	at java.desktop/java.awt.Window.addNotify(Window.java:791)
> 	at java.desktop/java.awt.Frame.addNotify(Frame.java:495)
> 	at java.desktop/java.awt.Window.show(Window.java:1053)
> 	at java.desktop/java.awt.Component.show(Component.java:1728)
> 	at java.desktop/java.awt.Component.setVisible(Component.java:1675)
> 	at java.desktop/java.awt.Window.setVisible(Window.java:1036)
> 	at andy_test/goryachev.apps.EmbeddedFrameBug.setFrameVisible(EmbeddedFrameBug.java:51)
> 	at andy_test/goryachev.apps.EmbeddedFrameBug.lambda$1(EmbeddedFrameBug.java:45)
> 	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.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)
> ```
> 
> 2. on primary retina monitor, the UI looks good:
> 
> <img alt="Screenshot 2023-07-07 at 09 18 05" width="412" src="https://user-images.githubusercontent.com/107069028/251800082-dbb3da3f-5b92-4d5b-b153-0a8e3e8df9ea.png">
> on the secondary, not so good:
> 
> ![Screenshot 2023-07-07 at 09 18 01](https://user-images.githubusercontent.com/107069028/251800216-abed1cbe-b426-476c-82c5-39f223cde31b.png)

That is tracked on different bugid https://bugs.openjdk.org/browse/JDK-8222209

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1171#issuecomment-1625672987


More information about the openjfx-dev mailing list