Skip to content
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

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

Closed
LeeeSe opened this issue May 17, 2024 · 4 comments · Fixed by #5365
Closed

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

LeeeSe opened this issue May 17, 2024 · 4 comments · Fixed by #5365
Labels
a:backend-winit Winit backend (mS,mO) a:platform-macos Issues specific to macOS (mS,bF) a:renderer-skia Skia Renderer (mS) bug Something isn't working

Comments

@LeeeSe
Copy link

LeeeSe commented May 17, 2024

Area.mp4

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
Copy link
Member

ogoffart commented Jun 4, 2024

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

@ogoffart ogoffart added bug Something isn't working needs info Further information from the reporter is requested a:layouts Related to the layouting and positioning of the elements (mO,bT) labels Jun 4, 2024
@LeeeSe
Copy link
Author

LeeeSe commented Jun 4, 2024

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
Copy link
Member

tronical commented Jun 6, 2024

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 tronical added a:platform-macos Issues specific to macOS (mS,bF) and removed needs info Further information from the reporter is requested a:layouts Related to the layouting and positioning of the elements (mO,bT) labels Jun 6, 2024
@tronical
Copy link
Member

tronical commented Jun 6, 2024

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.

@tronical tronical added a:backend-winit Winit backend (mS,mO) a:renderer-skia Skia Renderer (mS) labels Jun 6, 2024
tronical added a commit that referenced this issue Jun 6, 2024
Commit 1e450ab originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
tronical added a commit that referenced this issue Jun 6, 2024
Commit 1e450ab originally fixed this. Meanwhile, after many refactorings, this doesn't work anymore for the FemtoVG renderer. That's because the contents placement (or layer's contents gravity) is set before the hidden layer NSOpenGLContext creates is associated with the view.

For the Skia GL surface that already works, but for clarify the code is moved into the same location.

For Skia Metal rendering, apply the same on the metal layer (through the view). For this to work the contents scale also needs to be applied. To avoid further visual effects, the scale needs to be applied as early as possible, so apply it right after creating the
surface and latest at rendering time.

Fixes #5258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:backend-winit Winit backend (mS,mO) a:platform-macos Issues specific to macOS (mS,bF) a:renderer-skia Skia Renderer (mS) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants