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

Renderer still visit elements with zero opacity #6056

Open
mgejke opened this issue Sep 9, 2024 · 4 comments
Open

Renderer still visit elements with zero opacity #6056

mgejke opened this issue Sep 9, 2024 · 4 comments
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) optimization

Comments

@mgejke
Copy link

mgejke commented Sep 9, 2024

Rust on Windows 11.

Using the code below to be able to fade Spinner in and out based on busy, CPU usage is high when busy is false.

Spinner {
        indeterminate: true;
        opacity: busy ? 1.0 : 0.0;
        animate opacity { duration: 0.25s; }
    }

The following doesnt affect CPU usage when busy is false.

Spinner {
        indeterminate: true;
        visible: busy;
    }

I would expect Widgets that have opacity = 0 to not be drawn and not affect performance.
Also, maxing out a CPU core to display a Spinner seems a bit overkill.

@ogoffart
Copy link
Member

ogoffart commented Sep 9, 2024

Thanks for filling an issue.

The workaround here is to do visible: opacity > 0;
I wonder if there should be an optimization in the renderer for this to not visit elements that have a 0 opacity.

@ogoffart ogoffart changed the title Spinner counts as visible when opacity is 0.0 Renderer still visit elements with zero opacity Sep 9, 2024
@ogoffart ogoffart added a:builtin elements The runtime data structures related to the items (mO,bT) optimization labels Sep 9, 2024
@mgejke
Copy link
Author

mgejke commented Sep 9, 2024

Why didn't I think of that. 🤦‍♂️
Thanks!

@NigelBreslaw
Copy link
Member

Items that are zero opacity will still have a width and height though? So say it's a grid, setting visible false will free up a space. While opacity zero correctly keeps that grid space full. But showing nothing.

@ogoffart
Copy link
Member

ogoffart commented Sep 9, 2024

@NigelBreslaw Yes. but we shouldn't query so much the children elements properties that are only used for rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:builtin elements The runtime data structures related to the items (mO,bT) optimization
Projects
None yet
Development

No branches or pull requests

3 participants