MacOS: Title bar flickering when animation is playing

Andy Goryachev andy.goryachev at oracle.com
Tue Jan 21 19:03:37 UTC 2025


Dear Pascal:

I cannot see the flicker (macOS 15.1.1 M1, using the laptop retina monitor with scale=2 or the external monitor at scale=1), running the latest JFX master branch.
Actually, I don't see much change except for the button - the inner shadow of the window background looks unchanged.

Could it be something that was fixed?  Or due to x86 driver in your mac?  Or may be external monitor connection?

I can help with creating a JBS ticket once I can reproduce it.

Cheers,
-andy


From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of Pascal <pascal.gruen at gmail.com>
Date: Saturday, January 18, 2025 at 07:14
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: MacOS: Title bar flickering when animation is playing
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250121/a42e25df/attachment-0001.htm>


More information about the openjfx-dev mailing list