MacOS: Title bar flickering when animation is playing
Pascal
pascal.gruen at gmail.com
Sat Jan 18 15:12:35 UTC 2025
Hello all,
I have noticed a weird flickering behaviour on MacOS when playing
animations and having set an effect on the background (both needed to
be true during my experimentation).
It looks like JavaFX is drawing on the lower lines of the title bar
that are managed by the OS and during animation playing, JavaFX
"wins", overwriting the OS painting. Once the animation is finished,
the OS painting takes over again, resulting in a flicker effect
whenever an animation starts or stops.
Unfortunately, I cannot take a screenshot or screen recording, as the
flickering doesn't happen when screen recording is active. Somehow,
the painting process is different then.
I tested different resolutions and it looks to me that the flickering
happens independently of resolution and HiDPI setting.
It would be nice if someone could open a bug for this.
Below is the code to reproduce the behaviour (hover over the button to
see the flickering).
public class FlickerDemo extends Application {
@Override
public void start(Stage primaryStage) {
Button button = new Button("Button");
Transition transition = new Transition() {
{
setCycleDuration(Duration.millis(500));
}
@Override
protected void interpolate(double frac) {
button.setOpacity(Math.min(1, frac + 0.5));
}
};
button.setOnMouseEntered(_ -> {
transition.setRate(1.0);
transition.play();
});
button.setOnMouseExited(_ -> {
transition.setRate(-1.0);
transition.play();
});
StackPane root = new StackPane(button);
root.setBackground(new Background(new
BackgroundFill(Color.WHITE, null, null)));
root.setEffect(new InnerShadow());
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Thanks a lot!
Pascal
More information about the openjfx-dev
mailing list