Proposal: Rust Sync Engine — Eliminating iOS Background Sync Failures at the Architecture Level #26950
santoshakil
started this conversation in
Feature Request
Replies: 2 comments
|
This discussion has automatically been closed as it is likely a duplicate. We get a lot of duplicate threads each day, which is why we ask you in the template to confirm that you searched for duplicates before opening one. If you're sure this is not a duplicate, please leave a comment and we will reopen the thread if necessary. |
0 replies
|
This is not a duplicate. This is a new architectural proposal — not a bug report. The referenced issues (#22850, #22522, #22101, #22320, #20331) describe symptoms. This discussion proposes a Rust-based solution to their shared root cause (Dart isolate memory model). No existing discussion covers this approach. Please reopen. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The Root Cause: One Picture
Current — fragile lock coordination:
Proposed — shared Rust engine:
The Code Causing These Bugs
background.service.dart:Bug 1: Background gives up after 5 seconds (#22850 — 42 comments)
Foreground holds lock → background waits 5s → gives up → user's photos never upload.
Bug 2: False crash detection → concurrent writes (#22522 — 50 comments)
Foreground busy rendering → doesn't respond in 3s → background steals lock → both write → UNIQUE constraint failure.
Bug 3: Orphaned lock after kill (#22101, #20331 — 140 comments)
iOS kills background task → releaseLock() never called → next wake finds stale lock → 3s heartbeat timeout → starts from scratch → re-uploads everything.
The Rust Solution
All of the above code disappears. Replaced by:
Mutex::lock()— microsecondsWhy Pure Rust (The Dropbox Approach)
This follows the same principle Dropbox applied when they rewrote their sync engine in Rust ("Nucleus"). Their team called Rust "a force multiplier" and "one of the best decisions they made."
One engine, every language:
dart:ffidlopenJNIctypesAll call the same function, hit the same SQLite, protected by the same Mutex.
What it replaces:
What stays unchanged:
Proof of Concept
Built and tested:
force-stop/ app terminationPerformance (real device, debug mode):
Migration Path
No rewrite needed. Drop-in Flutter plugin:
Why This Can't Be Fixed in Dart
This isn't about Dart being slow. Dart is fine for sync logic. The problem is two Flutter engines sharing mutable state:
IsolateNameServer(name→SendPort registry) is the only coordination mechanismA Rust shared library's
staticis per-process, not per-isolate. Both engines see the same state. The compiler prevents data races. That's the fundamental difference.Happy to share the code and discuss the architecture in detail. I believe this approach would resolve the most painful mobile sync issues while keeping the Flutter UI completely unchanged.
MD Shakil Mia
GitHub · LinkedIn
All reactions