slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.95k stars 568 forks source link

Changing the window size during automatic layout will cause font jitter and blur. #5258

Closed LeeeSe closed 3 months ago

LeeeSe commented 4 months ago

https://github.com/slint-ui/slint/assets/44465325/90a9d9e5-d26a-43a3-9c98-cc0a873b2ebe

This problem will not affect normal use, but I still hope to get any solution. Very good GUI library, thank you for your work.

ogoffart commented 3 months ago

Thanks for filling a bug. Could you provide a small testcase we can use to reproduce the problem?

LeeeSe commented 3 months ago

sure

import { Button, VerticalBox, ScrollView } from "std-widgets.slint";

export component AppWindow inherits Window {
    VerticalBox {
        ScrollView {
            VerticalBox {
                Text {
                    text: "first first first first first first first first first first first";
                }

                Text {
                    text: "second second second second second second second second second second";
                }
            }
        }
    }
}

If you quickly change the size of the window, you will find the problem.

tronical commented 3 months ago

I can reproduce this. The NSView::setLayerContentsPlacement call we have is supposed to avoid this problem, but it seems that after all the refactoring it's now in a place where it's called too late.

So from what I can see, it jitters when using renderer-femtovg as well as renderer-skia (which defaults to metal on macOS), but it is smooth and jitter-free when using renderer-skia-opengl.

tronical commented 3 months ago

For the OpenGL renderer, the difference is the timing when NSView::setLayerContentsPlacement (or contentsGravity on the layer) is set. It must be done /after/ the NSOpenGLContext is associated with the view - I guess because the corresponding (hidden) layer doesn't exist until then. For Metal it's the same game, we're not setting that at all yet.