Environment
- flutter_gemma: 1.1.1
- flutter_gemma_litertlm: 1.0.2
- Platform: macOS 26.5.1 (25F80) — Apple Silicon arm64
- Hardware: Mac16,12 (MacBook Air M4, 16 GB)
- Metal: Metal 4, AGXMetalG16G_B0 v351.2
- Model:
gemma-4-E2B-it.litertlm (~2.5 GB from litert-community HuggingFace)
- Flutter: 3.41.6 (stable)
Description
Gemma 4 E2B inference fails on macOS 26.5.1 with two different failure modes depending on backend:
CPU backend (PreferredBackend.cpu)
Model loads successfully. Inference fails on first chunk with:
SEVERE: ERROR during chunk 0 inference: Exception: Stream error: INTERNAL: ERROR: [runtime/executor/llm_litert_compiled_model_executor.cc:734] Failed to invoke the compiled model
This is 100% reproducible — every chunk, every session.
GPU backend (PreferredBackend.gpu)
Model loads successfully. Within ~30s of starting inference, entire process crashes:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
Crashed thread (DartWorker) in dart::malloc() → _xzm_xzone_malloc_from_freelist_chunk.cold.1 — victim of prior heap corruption from LiteRtMetalAccelerator.framework. Multiple LiteRT threads active (execution_threa, callback_thread, worker pool) at crash time.
Full crash report attached below.
Context from existing issues
Steps to Reproduce
// Initialize with audio support
await FlutterGemma.initialize(inferenceEngines: const [LiteRtLmEngine()]);
await FlutterGemma.installModel(
modelType: ModelType.gemma4,
fileType: ModelFileType.litertlm,
).fromFile(modelPath).install();
final model = await FlutterGemma.getActiveModel(
maxTokens: 1024,
supportAudio: true, // ← triggers failure
supportImage: true,
preferredBackend: PreferredBackend.cpu,
);
final chat = await model.createChat(
supportAudio: true,
supportImage: true,
modelType: ModelType.gemma4,
);
// Send audio message — fails here
final audioBytes = await File('audio_chunk.wav').readAsBytes();
await chat.addQuery(Message.withAudio(
text: 'Transcribe this audio to English.',
audioBytes: audioBytes,
));
await for (final token in chat.generateChatResponseAsync()) {
// Never reaches here — stream errors with:
// Exception: Stream error: INTERNAL: ERROR:
// [runtime/executor/llm_litert_compiled_model_executor.cc:734]
// Failed to invoke the compiled model
}
Error Log (CPU backend)
2026-06-25 15:54:53.063659: [GemmaPipelineIsolate] SEVERE: ERROR during chunk 0 inference: Exception: Stream error: INTERNAL: ERROR: [runtime/executor/llm_litert_compiled_model_executor.cc:734] Failed to invoke the compiled model
2026-06-25 15:54:53.063993: [GemmaPipeline] SEVERE: chunk 0 error: Exception: Stream error: INTERNAL: ERROR: [runtime/executor/llm_litert_compiled_model_executor.cc:734]
Model initializes without errors (model path resolved, LiteRT engine created). Failure occurs only when generateChatResponseAsync / addQuery is called with audio data.
Crash Report (GPU backend)
Process: gemplay [77688]
Hardware Model: Mac16,12
OS Version: macOS 26.5.1 (25F80)
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018eee9bac
Application Specific Information:
BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
Abort Cause 38188534784
Triggered by Thread: 33 DartWorker
Thread 33 Crashed:: DartWorker
0 libsystem_malloc.dylib _xzm_xzone_malloc_from_freelist_chunk.cold.1 + 36
1 libsystem_malloc.dylib _xzm_xzone_malloc_from_freelist_chunk + 1004
2 libsystem_malloc.dylib _xzm_xzone_find_and_malloc_from_freelist_chunk + 336
3 libsystem_malloc.dylib _xzm_xzone_malloc_freelist_outlined + 324
4 FlutterMacOS dart::malloc(unsigned long) + 32
5 FlutterMacOS dart::VMHandles::AllocateHandle(dart::Zone*) + 68
...
10 FlutterMacOS dart::CallSiteInliner::TryInliningImpl(...)
...
21 FlutterMacOS dart::BackgroundCompiler::Run() + 252
Binary Images (relevant):
LiteRtLm.framework (native-v0.13.1 equivalent, arm64)
LiteRtMetalAccelerator.framework (arm64, 7.5 MB)
GemmaModelConstraintProvider.framework (arm64, 5.5 MB)
AGXMetalG16G_B0 (Apple M4 GPU driver, v351.2)
Active LiteRT threads at crash:
Thread 18-26: LiteRtLm thread_main (worker pool, 9 threads)
Thread 41: execution_threa in absl::Mutex::AwaitCommon
Thread 42: callback_thread in absl::Mutex::AwaitCommon
Additional Notes
Related
- #268 — Gemma 4 E2B works on macOS 26.2 M4 (vision+text, no audio)
- #218 — iOS 26.2 Gemma 4 E2B SIGSEGV (fixed in 0.14.0)
- LiteRT#6745 — Upstream Metal accelerator mispackaging
- #219 — macOS 26.4.1 SIGSEGV with Qwen 2.5
Environment
gemma-4-E2B-it.litertlm(~2.5 GB from litert-community HuggingFace)Description
Gemma 4 E2B inference fails on macOS 26.5.1 with two different failure modes depending on backend:
CPU backend (
PreferredBackend.cpu)Model loads successfully. Inference fails on first chunk with:
This is 100% reproducible — every chunk, every session.
GPU backend (
PreferredBackend.gpu)Model loads successfully. Within ~30s of starting inference, entire process crashes:
Crashed thread (DartWorker) in
dart::malloc()→_xzm_xzone_malloc_from_freelist_chunk.cold.1— victim of prior heap corruption fromLiteRtMetalAccelerator.framework. Multiple LiteRT threads active (execution_threa,callback_thread, worker pool) at crash time.Full crash report attached below.
Context from existing issues
supportAudio: true) on macOS 26.5.1.libLiteRtMetalAcceleratormispackaged, fixed in 0.14.0 FFI rewrite.Steps to Reproduce
Error Log (CPU backend)
Model initializes without errors (model path resolved, LiteRT engine created). Failure occurs only when
generateChatResponseAsync/addQueryis called with audio data.Crash Report (GPU backend)
Additional Notes
supportAudio: trueis the differentiating factor from [Bug] FastVLM-0.5B outputs raw <start_of_*> tokens on macOS (M4) — text and vision both broken #268 where Gemma 4 E2B worked on macOS 26.2 M4 with vision+text onlyIsolate.spawn) — same as gemplay's production pathRelated