Skip to content

bug: regression: page not updating in time when calling page.services.append() and page.push_route() #6327

@Creeper19472

Description

@Creeper19472

Duplicate Check

Describe the bug

When certain conditions are met simultaneously, the problem described in this Issue will occur, where controls fail to update to the interface in a timely manner, and may trigger exceptions such as "Control must be added to the page first".

Two key conditions have been confirmed:

  1. The specific call to fph.PermissionHandler() occurs. It is not yet confirmed whether other services will cause this issue, but fph.PermissionHandler() will cause this issue regardless of how it appears, including but not limited to being assigned to a variable, appearing alone, or as a parameter.
  2. At the same time, a call to page.push_route() must be made. It doesn't matter what the route parameter is or whether it actually exists.

The order of the two calls mentioned above is irrelevant.

Code sample

Code
import flet as ft
import flet_permission_handler as fph


class MonitorStack(ft.Stack):
    def __init__(self, ref: ft.Ref[MonitorStack] | None = None, visible=True):
        super().__init__(ref=ref, expand=True, visible=visible)
        self.controls = [
            ft.Text("Ready", size=14, color=ft.Colors.WHITE)
        ]


async def main(page: ft.Page):
    await page.push_route("/connect") # can be any route

    fph.PermissionHandler()

    ms = MonitorStack()
    page.overlay.append(ms)
    ms.controls[0].value = "Permissions service initialized"
    ms.update()  # will raise an exception
    
ft.run(main)

To reproduce

  1. Run the repro code
  2. The issue occurs. “Ready” will not show up in time unless you minimize and maximize the window.

Expected behavior

Test text should be displayed promptly.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11 (26200.8037)

Flet version

0.82.3.dev7890

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

This works for 0.82.3.dev7807

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions