fix: disable persistent file logging to stop UI stalls/ANRs#408
Open
dishit-wednesday wants to merge 2 commits into
Open
fix: disable persistent file logging to stop UI stalls/ANRs#408dishit-wednesday wants to merge 2 commits into
dishit-wednesday wants to merge 2 commits into
Conversation
Versions 0.0.88+ routed every logger.* call through a synchronous string build plus a react-native-fs append on the JS thread - capture() was not gated by __DEV__, so it ran in production. With ~480 call sites across hot paths (tool loop, LiteRT, downloads, whisper), this contended with the bridge and contributed to the 20s+ button-lag / ANR reports. logger.* is now a no-op in release builds (dev still mirrors to the console). Removes the appendPersistentLog / formatArg / write-queue / 2MB-trim machinery entirely. No behavior change beyond logging. Co-Authored-By: Dishit Karia <hanmadishit74@gmail.com>
e367bdf to
f8c5719
Compare
Newer Ollama versions (v0.6.4+) report multimodal support via a top-level `capabilities` array (e.g. ["vision", "tools"]) rather than via model_info keys. The old code only checked model_info, so models like Gemma 4 were always detected as non-vision. Now checks capabilities array first, falls back to model_info key scan, then projector_info keys. Also wires supportsToolCalling from the capabilities array. Co-Authored-By: Dishit Karia <hanmadishit74@gmail.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.
What
Two fixes in this PR:
1. Disable persistent file logging (stops UI stalls/ANRs)
logger.*is now a no-op in release builds (dev still mirrors to the console) — effectively a revert to the pre-0.0.88 logger behavior.2. Fix Ollama vision capability detection for newer models (Gemma 4, etc.)
Models pulled from Ollama v0.6.4+ (released April 2025) report vision support via a top-level
capabilitiesarray rather thanmodel_infokeys. The old detection only checkedmodel_info, so models likegemma4were never detected as vision-capable and the image attachment button would not appear.Why
Logger:
In 0.0.88+ the logger was changed so
capture()ran on everylogger.log/warn/errorcall without a__DEV__guard. In production that meant each call did:JSON.stringify/ string build on the JS thread, thenreact-native-fsappend (plus a periodic full-file read + 2MB trim) on a serial write queue.With ~480 call sites concentrated in hot paths (tool loop, LiteRT, downloads, whisper), this contended with the bridge and is a strong contributor to reported UI freezes / 20s+ button lag / ANRs. Nothing reads the log file — it was write-only.
Vision detection:
Ollama PR #10066 (v0.6.4, April 2025) added a top-level
capabilitiesarray to/api/show. Newer model formats like Gemma 4 only populate this array — they don't put clip/vision keys inmodel_info. Our code only knew about the old location, so these models were always detected as non-vision.Changes
src/utils/logger.ts— removeappendPersistentLog/formatArg/ the write-queue / the 2MB-trim and thereact-native-fsdependency.logger.*is a pure console wrapper, no-op in release.src/stores/remoteModelCapabilities.ts— checkcapabilitiesarray first, fall back tomodel_infokey scan, thenprojector_infokeys. Also wiressupportsToolCallingfrom thecapabilitiesarray.Both changes are deliberately minimal and safe for an immediate release.
Testing
eslintclean on changed files.remoteModelCapabilitiesunit tests: 25/25 pass.huihui_ai/gemma-4-abliterated:12b.