Study: upgrade flutter_edge_ai 2.3.2 → 2.7.2 — workarounds we can drop, new features, impact

Open
#329 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
dart, flutter

Research direction

Start with pubspec.yaml and choose a package set that resolves, then run the unit tests and integration_test/llm_stability_e2e_test.dart on the vivo 1933 with Qwen3 0.6B, Gemma 4 E2B, and DeepSeek R1. Record load time, first-token time, peak memory, and APK size, and re-test the plain Qwen file from #286. Completion means the upgrade’s compatibility, regressions, and costs are measured; migration and feature work are planned as separate PRs.

Written by the indexing model from the issue text.

Description

enhancement P2-Medium

Summary

We are on flutter_edge_ai 2.3.2 (_litertlm 1.13.2, _mediapipe 1.2.2, _embeddings 2.3.0, _diagnostics 0.2.2; native LiteRT-LM 0.18). Upstream is now at 2.7.2 (_litertlm 1.21.3, _mediapipe 1.3.1, _diagnostics 0.6.1; native LiteRT-LM 0.19.1). This issue studies, from the upstream changelogs, what the upgrade:

  • removes from our own workarounds,
  • adds that UNIUN can use,
  • costs.

Every claim below is from the changelogs, not tested yet. Phase 0 is to measure them.

1. Workarounds we may be able to remove

Our workaround (where) Why we have it Upstream change Expected result
Image turns use createChat(supportImage: true); text turns use openChat (local_llm_runner.dart ~206–222) A .litertlm engine rejected images on openChat sessions _litertlm 1.20.0: "openChat takes the model's own type and media", and openSession sessions are native conversations with media. Core 2.6.0 deprecates createChat/createSession until 3.0.0. One code path for every turn. We have to migrate before 3.0 anyway.
We add Qwen3's /no_think ourselves (prompt_parts.dart, gana_prompt_builder.dart, local_llm_runner.dart ~232) Stop Qwen3 thinking Core 2.7.0: "/no_think stays out of fullHistory; a replayed chat sends it once per turn" Check whether ours is now duplicated, then drop it if so.
A throwaway openChat per turn that re-feeds system + history + RAG (local_llm_runner.dart) Keep the runner stateless; surfaces must not clobber each other Core 2.6.0: "Engine SPI owns sessions, chat resolution, turn hooks and failed-turn rollback"; _litertlm 1.15.0: "a stopped turn is rewound in place"; 2.7.0 MessageTranscriptCodec Possibly reuse sessions and skip re-prefilling history each turn, which is faster replies on weak phones. Needs design + measurement.
Hand-written GPU→CPU fallback loops (embedding_service.dart ~93–98, gana_workmanager.dart ~482) GPU load can fail _litertlm 1.14.0: backends follow the file, plus backendFallback:; 1.21.0: Adreno GPU failures name the CPU Check for overlap; ours may become a single call.
Per-model maxTokens limits to avoid an engine abort (local_model_params.dart) Too-large maxTokens aborts at CalculatorGraph::Run Core 2.6.0: ContextLimitException for prompts over the window; _litertlm 1.18.0: thinkingTokenBudget Clear error instead of an abort; a cap on runaway Qwen3 thinking.
Model downloads and checks built by hand (ai_model_repository_impl.dart) — Core 2.5.5: installModelFromCatalog with expectedSize checks; 2.5.3: uninstallModel closes the loaded model Catch truncated downloads; simpler delete and logout.
Pins in pubspec.yaml: background_downloader: 9.5.6, hooks: ^2.0.0 override 9.5.7 broke our Android Kotlin build; openmls pins hooks ^1 Native hook moved to litertlm_dart (1.21.0) Re-test: maybe drop one or both pins.
Keep: Qwen3 0.6B uses Qwen3-0.6B_dynamic_wi4b32_afp32.litertlm (#286) Plain file fails on LiteRT-LM ≥ 0.17 Only a README note (1.13.3, #659), no runtime fix listed Keep it, but re-test the plain file on native 0.19.1.

2. New things UNIUN can use

Upstream feature Where it helps us User impact
Native library loads off the calling isolate (_litertlm 1.19.1, #756) Model load on the UI isolate Less jank when Shiv starts. Ties to #316 and #306. Measure.
MediaPipe 1.3.0: "a streamed reply no longer loses chunks while the UI thread is busy"; failed turns leave history DeepSeek R1 runs on MediaPipe Fixes possibly-missing text in R1 replies. Relates to #217.
Android GPU keeps Gemma 4 at FP16 above 2,048 tokens (1.21.0); Adreno prefill flush only on Adreno (1.19.2) Long RAG prompts on Gemma 4 Long prompts on the GPU stay correct. Our vivo 1933 Adreno GPU crash (AUDIT) needs re-testing.
flutter_edge_ai_rag 1.2–1.3: hybrid text + vector search (RRF), removeWhere Our retrieval is vector-only, plus a separate Hindi keyword path Better Hindi/Hinglish recall. Relates to #107. Compare with our tostore store before adopting.
flutter_edge_ai_speech 0.6.x: on-device STT (Whisper, Parakeet, Moonshine) and TTS (incl. Qwen3-TTS, 11 languages) Voice input to Shiv or the composer Relates to #215.
Experimental Decider (pick 1 of N or abstain) Gana's <NOOP> skip, the small-model relevance cut-off Possibly more reliable skip decisions than parsing text. Experimental, so study only.
Structured tool calls (2.4.x) Future Shiv actions Later.
flutter_edge_ai_diagnostics 0.6.1: memory on Windows, macOS and Linux; iOS peak; gpuMemory() on Adreno Performance work Real numbers for #316 and #306.

3. Costs and risks

  • Breaking: core 2.5.0 removes the members deprecated for 2.5.0 (see upstream MIGRATION.md). 2.6.0 deprecates createSession/createChat/session/chat and moves createDecider. _litertlm 1.14.0 changes Gemma 4 audio order and throws LiteRtLmBundleException on wrong-backend files.
  • Version constraints: _litertlm 1.20.1 needs core >=2.6.0 <2.7.0, so pick a set that pub get resolves (likely core 2.7.2 + _litertlm 1.21.3) rather than bumping each package blindly.
  • New native bundle (0.18 to 0.19.1): every model on every backend can change behaviour. Re-run integration_test/llm_stability_e2e_test.dart and the Shiv/Gana/RAG device tests on the vivo 1933 for Qwen3 0.6B, Gemma 4 E2B and DeepSeek R1.
  • App size and download size: unknown; measure the APK before and after.
  • iOS: cannot be built here; only CI compile.

Plan

  1. Phase 0, measure: branch, bump to a resolving set, run unit tests and the device tests above. Record load time, first-token time and peak memory with the new diagnostics, plus APK size. Re-test #286 with the plain Qwen file.
  2. Phase 1, migrate APIs: createChat/createSession to openChat/openSession (one path for images); drop duplicated /no_think; adopt ContextLimitException.
  3. Phase 2, remove workarounds that Phase 0 proved fixed: fallback loops, pins, download checks.
  4. Phase 3, new features as separate issues: hybrid RAG search, speech, session reuse.

Each phase is its own PR with before/after numbers.

Dominant language
Dart
Stars
2
Forks
2
Avg merge
3d 5h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from basictech01/uniun

All issues in basictech01/uniun

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.