Require llama.swift 2.10549.0 and free the lazy bitmap for rejected video input - #222
Merged
Merged
Conversation
…ideo input The four-argument mtmd_helper_bitmap_init_from_buf that returns mtmd_helper_bitmap_wrapper first appears in llama.cpp b10549, so older 2.x releases of llama.swift can no longer build the Llama trait. When the helper decodes a buffer as video, it returns a lazily initialized bitmap alongside the video context; free both before rejecting the input.
There was a problem hiding this comment.
🟢 Approval recommended
The dependency floor change matches the pinned resolved version and the added bitmap free cleanly addresses a confirmed leak in the rejected-video path without altering other control flow.
Pull request overview
This PR tightens the minimum supported llama.swift version to match the required mtmd helper API and fixes a resource leak when video input is detected but rejected, ensuring proper cleanup in the Llama mtmd integration.
Changes:
- Raise the
llama.swiftdependency floor to2.10549.0to ensure the expectedmtmd_helper_bitmap_init_from_bufwrapper signature is available. - Free the lazily-initialized bitmap when the decoded input turns out to be video and the code throws
unsupportedFeature, preventing a bitmap leak.
File summaries
| File | Description |
|---|---|
| Sources/AnyLanguageModel/Models/LlamaLanguageModel.swift | Frees wrapper.bitmap before freeing the video context and throwing on rejected video input. |
| Package.swift | Updates the minimum llama.swift version to 2.10549.0 to match the required mtmd helper API surface. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Two follow-ups to #213.
Package.swiftstill allowed llama.swift from 2.7484.0, but the four-argumentmtmd_helper_bitmap_init_from_bufthat returnsmtmd_helper_bitmap_wrapperfirst appears in llama.cpp b10549 (b7484 has the three-argument form returningmtmd_bitmap *). A consumer resolving an older 2.x with the Llama trait would fail to compile, so the floor moves to 2.10549.0, whichPackage.resolvedalready pins.