Skip to content

WindowDragArea slows down nested functionality perfomance #5193

@desh0cc

Description

@desh0cc

Duplicate Check

Describe the bug

When using WindowDragArea, There's a noticeable slowdown when toggling page.window.maximized value. The same code works instantly when I remove it

Code sample

Code
import flet as ft, time

def main(page: ft.Page):
    page.window.title_bar_hidden = True

    def maximize(e, text):
        start = time.time()
        page.window.maximized = not page.window.maximized
        page.update()
        print(f"{text} updated in: {time.time() - start:.5f}")

    button_with_wda = ft.WindowDragArea(
        ft.Container(
            ft.Icon(
                ft.Icons.ABC,
                size=30
            ),
            on_click=lambda e: maximize(e, "With WDA")
        )
    )
    
    button_without_wda = ft.Container(
        ft.Icon(
            ft.Icons.ABC,
            size=30
        ),
        on_click=lambda e: maximize(e, "Without WDA")
    )
    

    page.add(button_with_wda)
    page.add(button_without_wda)

if __name__ == "__main__":
    ft.app(target=main)

To reproduce

  1. Run the code
  2. Click both buttons several times
  3. Observe console timing
  4. Compare times

Expected behavior

No response

Screenshots / Videos

Operating System

Windows

Operating system details

Windows 11

Flet version

0.27.6

Regression

No, it isn't

Suggestions

No response

Logs

No response

Additional details

I tested it with time.time() and found that it's not always slower, but the interface still feels noticeably less responsive, especially when you press it quickly, or your project's bigger

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions