Skip to content

fix: disable persistent file logging to stop UI stalls/ANRs#408

Open
dishit-wednesday wants to merge 2 commits into
mainfrom
fix/disable-persistent-logger
Open

fix: disable persistent file logging to stop UI stalls/ANRs#408
dishit-wednesday wants to merge 2 commits into
mainfrom
fix/disable-persistent-logger

Conversation

@dishit-wednesday

@dishit-wednesday dishit-wednesday commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

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 capabilities array rather than model_info keys. The old detection only checked model_info, so models like gemma4 were 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 every logger.log/warn/error call without a __DEV__ guard. In production that meant each call did:

  • a synchronous JSON.stringify / string build on the JS thread, then
  • a react-native-fs append (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 capabilities array to /api/show. Newer model formats like Gemma 4 only populate this array — they don't put clip/vision keys in model_info. Our code only knew about the old location, so these models were always detected as non-vision.


Changes

src/utils/logger.ts — remove appendPersistentLog / formatArg / the write-queue / the 2MB-trim and the react-native-fs dependency. logger.* is a pure console wrapper, no-op in release.

src/stores/remoteModelCapabilities.ts — check capabilities array first, fall back to model_info key scan, then projector_info keys. Also wires supportsToolCalling from the capabilities array.

Both changes are deliberately minimal and safe for an immediate release.


Testing

  • eslint clean on changed files.
  • All logger consumers mock the logger; full related test suite (127 suites) passes.
  • remoteModelCapabilities unit tests: 25/25 pass.
  • Vision detection verified end-to-end on device against a live Ollama server with huihui_ai/gemma-4-abliterated:12b.

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>
@dishit-wednesday dishit-wednesday force-pushed the fix/disable-persistent-logger branch from e367bdf to f8c5719 Compare June 20, 2026 08:09
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>
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