IssueRaiser

Merge the platform and UI threads

### Update 5/20/2025 As of Flutter 3.32 stable, threads are merged by default on iOS and Android with a flag available to opt-out. In Flutter 3.33 beta changes have landed so that threads will also be merged by default on Windows and macOS. Work to merge threads on Linux is WIP. We expect that the ability to opt-out of merged threads will be removed in a later release. Known issues: * [x] https://github.com/flutter/flutter/issues/163064 * [x] https://github.com/flutter/flutter/issues/175135 * [x] https://github.com/flutter/flutter/issues/173843 ___ Currently Flutter has a separate UI thread (that runs dart code) and platform thread. I *think* the main purpose of the UI thread is to prevent blocking the platform thread, but the actual benefit of this eludes me. In most applications the platform thread stays idle apart from tiny amount of work during event processing and compositing. The work is moved to UI thread, but if the work doesn't complete in time, it causes jank just like it would when blocking the platform thread. The drawbacks however seem pretty clear. The vast majority of platform APIs need to be accessed on platform thread. This means that instead of being able to call the API from Dart directly (i.e. through FFI), platform channels or something similar need to be used to marshal the call to platform thread. This adds some friction and asynchronous behavior to what could otherwise be simple synchronous call. Situation gets even more complicated the other

Posted by knopp on Jun 19, 2024, 10:30 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

ux (Sysadmin)

Merge the platform and UI threads

knoppJun 19, 2024, 10:30 PM

### Update 5/20/2025 As of Flutter 3.32 stable, threads are merged by default on iOS and Android with a flag available to opt-out. In Flutter 3.33 beta changes have landed so that threads will also be merged by default on Windows and macOS. Work to merge threads on Linux is WIP. We expect that the ability to opt-out of merged threads will be removed in a later release. Known issues: * [x] https://github.com/flutter/flutter/issues/163064 * [x] https://github.com/flutter/flutter/issues/175135 * [x] https://github.com/flutter/flutter/issues/173843 ___ Currently Flutter has a separate UI thread (that runs dart code) and platform thread. I *think* the main purpose of the UI thread is to prevent blocking the platform thread, but the actual benefit of this eludes me. In most applications the platform thread stays idle apart from tiny amount of work during event processing and compositing. The work is moved to UI thread, but if the work doesn't complete in time, it causes jank just like it would when blocking the platform thread. The drawbacks however seem pretty clear. The vast majority of platform APIs need to be accessed on platform thread. This means that instead of being able to call the API from Dart directly (i.e. through FFI), platform channels or something similar need to be used to marshal the call to platform thread. This adds some friction and asynchronous behavior to what could otherwise be simple synchronous call. Situation gets even more complicated the other

Comments (0)

No comments yet. Start the discussion.

Comment on this issue