Skip to content

feat(apple/flutter): 0.9.0 iOS/macOS integration, mobile API, deterministic dispose & context shift support - #109

Closed
sebasbad wants to merge 1 commit into
netdur:mainfrom
sebasbad:feat/0.9.0-ios-macos-flutter-support
Closed

feat(apple/flutter): 0.9.0 iOS/macOS integration, mobile API, deterministic dispose & context shift support#109
sebasbad wants to merge 1 commit into
netdur:mainfrom
sebasbad:feat/0.9.0-ios-macos-flutter-support

Conversation

@sebasbad

@sebasbad sebasbad commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Consolidates all fixes and enhancements required for seamless mobile & desktop (iOS/macOS) integration, resource safety, and long-reasoning model support in llama_cpp_dart 0.9.0.

Key Changes

1. Platform & Plugin Declarations (pubspec.yaml, ios/llama_cpp_dart.podspec)

  • Added ffiPlugin platform configuration for ios and macos.
  • Added vendored Podspec configuration pointing to dynamic Llama.xcframework with module definitions and pod target xcconfigs.

2. Apple XCFramework Build Script (tool/build_apple_xcframework.sh)

  • Updated build script to package a self-contained dynamic Llama.xcframework with universal iOS simulator (arm64 + x86_64) and universal macOS (arm64 + x86_64) slices.
  • Fixed executable binary name casing (Llama.framework/Llama) and normalized CFBundleIdentifier format.

3. Mobile-First API Extensions (lib/src/)

  • Added ContextParams.mobile preset tuned for memory constraints on mobile devices.
  • Added estimateVramBytes() helper to LlamaModel.
  • Added isDisposed flag for status checks.
  • Added support for cancelling ongoing generations in EngineChat.

4. Deterministic C++ VRAM Teardown (lib/src/isolate/)

  • Ensures worker isolate shutdown explicitly disposes C++ native pointers (LlamaModel, LlamaContext, MultiModalInstance) to prevent VRAM memory leaks.

5. Context Shift Support for Reasoning Models (lib/src/isolate/)

  • Exposed shiftPolicy and shift named parameters in EngineChat.generate() and GenerateChatCommand, enabling opt-in auto context sliding for models with high token output.

6. Documentation (example/README.md)

  • Added documentation for running probe CLI examples (engine_stream.dart, chat_two_turn.dart, version_info.dart).

Verification & Testing

  • Physical iOS Device & macOS Release: Verified full build, dynamic framework embedding, and runtime execution in release Flutter apps.
  • Probe Scripts Executed: Tested example/probes/engine_stream.dart and example/probes/chat_two_turn.dart using Qwen2.5-0.5B model; verified multi-turn conversation memory, Jinja template rendering, token streaming, and clean VRAM deallocation.

…nistic dispose & context shift support

Consolidate mobile & Apple ecosystem enhancements for llama_cpp_dart 0.9.0 release:

- Platform Support: Declare Flutter ffiPlugin support for iOS and macOS in pubspec.yaml and ios/llama_cpp_dart.podspec.
- Apple XCFramework: Build script fixes for self-contained dynamic Llama.xcframework (universal simulator arm64+x86_64, universal macos arm64+x86_64, executable name fix, bundle id normalization).
- Mobile-First API: Added ContextParams.mobile preset, estimateVramBytes(), model.isDisposed, and engine worker chat cancel.
- Resource Safety: Deterministic C++ VRAM teardown for model, context, and multimodal instances on isolate shutdown.
- Reasoning Models: Exposed ContextShiftPolicy in EngineChat.generate() for auto context sliding on reasoning/thinking models.
@sebasbad
sebasbad force-pushed the feat/0.9.0-ios-macos-flutter-support branch from 82ca8e1 to c82fd85 Compare August 1, 2026 00:17
@sebasbad

sebasbad commented Aug 1, 2026

Copy link
Copy Markdown
Author

Closing in favor of unified PR #110 (#110) which consolidates iOS, macOS, and Android NDK support into a single PR.

@sebasbad sebasbad closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant