-
Notifications
You must be signed in to change notification settings - Fork 120
Reduce worker_manager memory allocation #4435
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6833140
Reduce worker_manager memory allocation
tddang-linagora e6fdce1
fixup! Reduce worker_manager memory allocation
tddang-linagora 9943d45
fixup! Reduce worker_manager memory allocation
tddang-linagora 3237c91
Remove unused flutter_downloader and workmanager
tddang-linagora 7b3ad5c
fixup! Reduce worker_manager memory allocation
tddang-linagora 7efdc48
Add ADR-0079 Tmail memory allocation optimization
tddang-linagora d34bf17
fixup! Add ADR-0079 Tmail memory allocation optimization
tddang-linagora 368d6ce
fixup! Add ADR-0079 Tmail memory allocation optimization
tddang-linagora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,3 @@ | ||
| <resources> | ||
| <string name="app_name">Twake Mail</string> | ||
| <string name="flutter_downloader_notification_started">Started</string> | ||
| <string name="flutter_downloader_notification_in_progress">In Progress</string> | ||
| <string name="flutter_downloader_notification_canceled">Canceled</string> | ||
| <string name="flutter_downloader_notification_failed">Failed</string> | ||
| <string name="flutter_downloader_notification_complete">Completed</string> | ||
| <string name="flutter_downloader_notification_paused">Paused</string> | ||
| </resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # 0079 - Reduce Twake Mail mobile memory usage | ||
|
|
||
| Date: 2026-04-09 | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| ## Context | ||
|
|
||
| Twake Mail is allocating a lot of memory on mobile. | ||
| - ~375 MB on Android (Oneplus 8T) | ||
|
|
||
| <img src="../images/android-before-4435.png"> | ||
|
|
||
| - ~297 MB on iOS (iPhone 11 Pro) | ||
|
|
||
| <img src="../images/ios-before-4435.png"> | ||
|
|
||
| ## Findings | ||
|
|
||
| ### `worker_manager` library's inefficient memory allocation (Android & iOS) | ||
| - Version `5.0.3` counts the number of processors (x) on the device, create forever-live x - 1 isolates | ||
| - Version `7.2.7` adds an ability to create isolate on-demand, and dispose when done. However, it still leaks 1 isolate when init. | ||
| ### `firebase_messaging` library's eager background Dart isolate (Android) | ||
| - FirebaseMessaging.onBackgroundMessage() creates a forever-live isolate even when the app is in foreground. | ||
| - Related: https://github.com/firebase/flutterfire/issues/17163 | ||
| ### Unused `flutter_downloader` library's worker (iOS) | ||
| - The only usage was deleted in https://github.com/linagora/tmail-flutter/commit/be8eaf625818b17e60ca65846053cb8c26a71a15#diff-451741ba5146e6ad711c77e4c2fe34958a36595e4926cd43c2ddb97586ef6d88, but the library and initialization process remained, causing 1 forever-live isolate. | ||
|
|
||
| ## Decision | ||
|
|
||
| ### `worker_manager` | ||
| - Upgrade to `7.2.7` | ||
| - Create an upstream fix for init's isolate leak | ||
| ### `firebase_messaging` | ||
| - Wait for https://github.com/firebase/flutterfire/pull/18122, update when merged | ||
| ### `flutter_downloader` | ||
| - Remove the library | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Android: ~118 MB | ||
|
|
||
| <img src="../images/android-after-4435.png"> | ||
|
|
||
| - iOS: ~78 MB | ||
|
|
||
| <img src="../images/ios-after-4435.png"> | ||
|
|
||
| - No changes for web | ||
|
|
||
| | Before | After | | ||
| | :--- | :--- | | ||
| | <img src="../images/web-before-4435.png"> | <img src="../images/web-after-4435.png"> | | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add alt text to all ADR images.
All embedded images are missing
alttext (MD045), which hurts accessibility and fails current lint checks.Suggested patch
Also applies to: 18-18, 45-45, 49-49, 55-55
🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 14-14: Images should have alternate text (alt text)
(MD045, no-alt-text)
🤖 Prompt for AI Agents