flet icon indicating copy to clipboard operation
flet copied to clipboard

Improve Flet Performance

Open FeodorFitsner opened this issue 10 months ago • 13 comments

Discussed in https://github.com/flet-dev/flet/discussions/5940

Originally posted by qyddss December 25, 2025

Question

Why has my old project become extremely laggy after updating to 0.8? What’s going on? What areas do I need to pay attention to to avoid this issue? Uploading QQ20251226-8554.zip…

Code sample

No response

Error message

No response

------------------------------------------------------

  • [X] I have searched for answers to my question both in the issues and in previous discussions.

FeodorFitsner avatar Jan 30 '26 18:01 FeodorFitsner

The app from this discussion is indeed quite slow on the current version. However, I wasn’t able to run it on 0.28.3 for comparison.

In your opinion, what could be the problem? Where would you start investigating?

7576457 avatar Jan 30 '26 19:01 7576457

The app is a complex one with a lot of controls.

First of all I have a few general optimizations in mind that could make Flet tree comparison faster. After that I can see if that improves that app.

FeodorFitsner avatar Jan 30 '26 19:01 FeodorFitsner

Any General performance optimizations you can give out? @FeodorFitsner

HappyCoder256 avatar Feb 05 '26 13:02 HappyCoder256

I discovered a performance bottleneck in Flet 1.0. When controls are deeply nested, accessing properties deep within the hierarchy causes a significant performance drop, like this: demo_control.content.content.content.height. In contrast, accessing demo_control.height directly is very fast. This could be one of the reasons for the performance gap between version 1.0 and older versions.

Qye-Leisure avatar Feb 26 '26 17:02 Qye-Leisure

Performance optimization is on our TODO list with high priority.

FeodorFitsner avatar Feb 26 '26 18:02 FeodorFitsner

I’m now almost certain that excessive nesting depth makes the UI lag significantly. Just like my screen recording shows, the whole UI becomes laggy as soon as a complex component with deep nesting is added. 这好像无法添加录屏

Qye-Leisure avatar Feb 28 '26 13:02 Qye-Leisure

I discovered a performance bottleneck in Flet 1.0. When controls are deeply nested, accessing properties deep within the hierarchy causes a significant performance drop, like this: demo_control.content.content.content.height. In contrast, accessing demo_control.height directly is very fast. This could be one of the reasons for the performance gap between version 1.0 and older versions.

So I have flet 0.28.3, should I completely abandon control hierarchy calls

HappyCoder256 avatar Mar 01 '26 14:03 HappyCoder256

I’m also encountering a performance issue in my Flet app when it’s built as an executable (Windows .exe) or as an Android APK. Here’s the situation: The app works fine offline — the UI loads instantly and page updates are very fast. When the app has an active internet connection and needs to fetch images, the page updates become noticeably slower. I suspect that fetching images over the internet is interfering with the WebSocket communication that Flet uses internally, which could be causing the slowdown. What I’ve tried so far: Running the app without internet — works perfectly, UI is instant. Observing performance with internet — noticeable lag on page updates. AND NOT ONLY IMAGES BUT WHEN I HAVE INTERNET on, the page updates feel laggy, what should literally be done. I think its all about internal routing

HappyCoder256 avatar Mar 01 '26 14:03 HappyCoder256

我在 Flet 1.0 中发现了性能瓶颈。当控件深度嵌套时,访问层级结构深层的属性会导致显著的性能下降,如下:demo_control.content.content.content.height。相比之下,直接访问 demo_control.height 非常快。这可能是 1.0 版本与旧版本性能差距的原因之一。

我有 flet 0.28.3,我是否应该完全放弃控制层级调用

0.28.3 I don't know, I haven't developed complex applications with this version, but 0.8, according to my experience, you need to reduce the depth of the layer and the number of controls on the page as much as possible, and the refresh is best to be a one-time batch refresh, and the refresh range is as small as possible, if your page is not very complicated, just a few deep controls should not affect the use,

Qye-Leisure avatar Mar 01 '26 23:03 Qye-Leisure

But y, yet Flutter itself is faster. What is really causing too much performance drop?

HappyCoder256 avatar Mar 02 '26 05:03 HappyCoder256

Man Flet is 100% testing our optimisation skills

HappyCoder256 avatar Mar 02 '26 05:03 HappyCoder256

但 Y,Flutter 本身更快。到底是什么导致了性能过大下降?

I'm also curious about the reason for this problem, I have high hopes for Flet, I thought it would be better than some web frameworks, even if it wasn't as good as Flutter itself, and my node editor has changed several times, all because of performance issues. I've changed to autism

Qye-Leisure avatar Mar 02 '26 05:03 Qye-Leisure

I’m also encountering a performance issue in my Flet app when it’s built as an executable (Windows .exe) or as an Android APK. Here’s the situation: The app works fine offline — the UI loads instantly and page updates are very fast. When the app has an active internet connection and needs to fetch images, the page updates become noticeably slower. I suspect that fetching images over the internet is interfering with the WebSocket communication that Flet uses internally, which could be causing the slowdown. What I’ve tried so far: Running the app without internet — works perfectly, UI is instant. Observing performance with internet — noticeable lag on page updates. AND NOT ONLY IMAGES BUT WHEN I HAVE INTERNET on, the page updates feel laggy, what should literally be done. I think its all about internal routing

Any one experienced this?

HappyCoder256 avatar Mar 06 '26 11:03 HappyCoder256