Repository navigation
fix(ai): recognize an installed model on launch; never ask macOS for the GPU - #329
Merged
Merged
Conversation
…the GPU Two defects from one device session. The interpreter boots at needsDownload and only refresh() consults the disk, but nothing ever called refresh() — so an already-downloaded model read as missing on every launch, and the shell's onPause dispose() had no mirror, dropping the same way on a background cycle. HomeShell now restores on mount and on onRestart, gated on aiEnabled so an AI-off run never constructs the interpreter at all. The "Download model" tap that followed then found the file already installed and fell straight through to the load, which SIGSEGV'd the process on macOS: with backend=gpu, LiteRT's ReplaceMagicNumbersIfAny reads a garbage config count (num_configs=4294967300, i.e. 4 + 2^32), walks off the array, and faults inside its own logger on a null char*. That is the same shape as the iOS Metal null-deref already handled here — a native crash, so _loadModel's step-down ladder can never catch it and fall back. The backend list moves into a testable backendsFor(platform); macOS joins iOS as CPU-only, which is the path that had been loading the file successfully all along. Device-verified on macOS: the app restores the model on launch and stays up where it previously died about two seconds in. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
refresh()had zero call sites — the interpreter boots atneedsDownloadand onlyrefresh()checks disk, so a downloaded model read as missing on every relaunch.HomeShellnow restores on mount and ononRestart(the mirror of the existingonPausedispose), gated onaiEnabledso an AI-off run never constructs the interpreter.backend=gpu, LiteRT'sReplaceMagicNumbersIfAnyreadsnum_configs=4294967300(4 + 2^32), walks off the array, and faults inside its own logger on a nullchar*.GemmaInterpreterService.backendsFor(platform); macOS joins iOS as CPU-only. A native crash kills the process before_loadModel's catch runs, so the step-down ladder can never fall back — same reasoning already documented for the iOS Metal null-deref.test/interpreter_restore_test.dart: backend table per platform, refresh-on-launch when AI is enabled, no interpreter touch when it's off.Evidence: crash report
juice-2026-08-12-181046.ips(KERN_INVALID_ADDRESS at 0x80inLiteRtStandardLoggerT::Log←ReplaceMagicNumbersIfAny) plus the plugin's native log namingbackend=gpuand the bad config count.Test plan
Model gemma-4-E4B-it.litertlm installed: true, maps the model + XNNPACK weight cache, and stays up — previously it died ~2s in. Processsampleshows engine creation completed rather than hung.🤖 Generated with Claude Code