← All posts

Debugging BlindReading Crashes and ANRs Without a Crash SDK

8th September, 2026
[liblitertlm_jni.so] Java_com_google_ai_edge_litertlm_LiteRtLmJni_nativeSendMessageAsync
SIGSEGV · In production · Google Pixel 9a · Android 16 · Version 0.0.95
backtrace:
  #00  pc 0x00000000004c6c8c  …/liblitertlm_jni.so (BuildId: c2c27170ba409dbd0bc01820fa738580)
  #02  pc 0x00000000004b2af4  …/liblitertlm_jni.so (…nativeSendMessageAsync+608)
  #05  pc 0x000000000021be2a  …/base.apk (com.google.ai.edge.litertlm.Conversation$JniMessageCallbackImpl.onDone+58)
  #19  pc 0x000000000007b3b4  /apex/…/bionic/libc.so (__start_thread+68)

That is all we got. No user, no steps, no logs: a few frames copied out of Play Console. Off Grid is a private, on-device AI app, so we never shipped a crash SDK either. No Sentry, no Crashlytics, and when we reconsidered one in June we dropped it again for the same privacy reason. This post is the case file from the months when our Android vitals turned red: how we read reports like the one above, what we tried that didn't work, and what's still open.

Foundation : sort before you read

Before reading a single frame, put the report in one of three buckets. To a user they look the same ("the app died"). To us they need completely different fixes.

Then rank by share, not by how scary a stack looks. In v0.0.100, one native library was two thirds of every Android crash:

Our sources were Play Console, Xcode Organizer, adb logcat on our own phones, and GitHub issues. In July we started filing Play Vitals crashes and store reviews as GitHub issues automatically: 87 of them in two and a half weeks. That's the closest we got to a crash SDK without shipping one.

Case A : a crash inside someone else's library

Symptom
SIGSEGV in liblitertlm_jni.so, Google's LiteRT-LM library that runs our second AI engine. 65.2% of Android crashes in v0.0.100.
Evidence
A closed-source binary, and the stack above.
Status
Narrowed by three releases. Not closed.

We don't have the library's source. But every native frame carries a Build ID, and that's enough to start. The .so inside litertlm-android:0.11.0, the version we shipped, has the same Build ID: c2c27170…. So we were looking at the exact machine code that crashed. Then llvm-objdump on frame #00:

; frame #00  pc 0x4c6c8c  liblitertlm_jni.so (an internal function)
ldr  x8, [x21]          ; load the object's vtable
ldr  x9, [x8, #0x40]    ; load one of its virtual methods
add  x8, sp, #0x88
blr  x9                 ; call it  ← the object is already gone

A virtual method call faults like this when the object it calls into has already been freed. And nativeDeleteConversation is just 36 bytes: run the destructor, operator delete(848), done. It doesn't wait for anything still running. So: a native worker thread still uses a conversation that our close() already freed.

Two threads, one object, no handshake.

What we tried, in order:

The best lead came from re-reading frame #05: JniMessageCallbackImpl.onDone. In early June we let LiteRT run the tool-calling loop natively. In that loop, when a reply finishes, onDone sends the pending tool result back to the model on the worker thread, without checking whether the conversation is still alive. Our tool handler waits for its result inside a blocking call. When we close, we cancel pending tool calls, the handler returns at once, and the library re-sends on a conversation we are deleting. It fits the stack frame for frame. We haven't reproduced it yet, so it's our leading hypothesis, not a finding.

Case B : the ANR was our logger

Symptom
"Each UI interaction takes 10-15 seconds to respond … have to wait 30secs for it to load the app."
Evidence
The user's own clue: "This problem did not exist on v87."
Status
Fixed in v0.0.97.

"After v89 update. The app has become super laggy to the extent each UI interaction takes 10-15seconds to respond."

GitHub issue #324 · 26 April

That clue was exact, and we missed it for two months. v0.0.88 is the release that added a persistent log file, and it ran in production. Every logger.* call made an exists, an append and a stat, each a round trip across the React Native bridge. Once the file passed 2 MB, it read the whole file, kept the last 4,000 lines and wrote it back. We had about 480 log calls on hot paths: the tool loop, the AI engine, downloads, speech.

// src/utils/logger.ts (v0.0.88 to v0.0.96)
writeQueue = writeQueue.then(async () => {
  if (await RNFS.exists(path)) { await RNFS.appendFile(path, line, 'utf8'); }
  const stat = await RNFS.stat(path);
  if (size > MAX_LOG_FILE_BYTES) {                        // 2 MB
    const content = await RNFS.readFile(path, 'utf8');      // the whole file
    ...
function capture(level, args) { appendPersistentLog(level, args); }   // not __DEV__-gated

The fix in v0.0.97: logger.* does nothing in release builds. For debugging we later added a separate sink that buffers lines and flushes every 800 ms or 50 lines, capped at 5 MB, in dev builds only.

Case C : the boot screen that waited for everything

Symptom
The loading screen sat for 10+ seconds on a test phone.
Evidence
Device log, 18:43:55 to 18:44:06. Nine downloads were writing progress, and a database read waited ~9.5 s on the lock.
Status
Fixed in v0.0.103.

The read was slow, but the real bug was the shape of boot: the app awaited the whole download-recovery chain before showing any UI. Every step sat on the critical path.

The fix kept the recovery steps in the same order but took them off the boot gate. Screens read from stores and fill in when recovery lands. We proved it with a test that renders the real App with a database call that never returns. It was red before the fix ("loader stays forever") and green after:

// __tests__/integration/app/bootNotBlockedByDownloadDb.rendered.test.tsx
NativeModules.DownloadManagerModule = { ...NativeModules.DownloadManagerModule,
  getActiveDownloads: jest.fn(() => new Promise(() => {})) };   // never resolves
const view = rtl.render(React.createElement(App));
await rtl.waitFor(() => {
  expect(view.queryByTestId('app-loading')).toBeNull();
}, { timeout: 8000 });

Case D : the chat that froze while it talked

Symptom
The chat stuttered and froze during long replies.
Evidence
Tokens flush to the screen every 50 ms, about 20 times a second, and every flush re-rendered the whole chat.
Status
Mostly fixed in v0.0.101. One part still open.

On every flush, each message in the chat re-parsed its markdown, not just the one being written.

// src/screens/ChatScreen/MessageRenderer.tsx (v0.0.101)
-export const MessageRenderer: React.FC<MessageRendererProps> = (props) => {
+export function messageRendererPropsEqual(prev, next): boolean {
+  return prev.item === next.item && prev.index === next.index
+    && prev.isStreaming === next.isStreaming;   // on* callbacks deliberately NOT compared
+}
+export const MessageRenderer = React.memo(MessageRendererInner, messageRendererPropsEqual);

The comparator ignores the callbacks on purpose: "Comparing them would defeat the memo." Now only the message being written re-renders. That one message still re-parses its whole growing text on every flush, which is the part still open.

Case E : the kills, and the budgets we kept reverting

Kills have no stack. On one Nothing Phone, logcat showed Out of memory: Killed process with 2.1 GB of file-backed memory: we were loading an image model while a text model was still in RAM. A user's diagnostics from a Galaxy S25 Ultra showed 3.6 GB of process memory, 605 MB of graphics memory and 2.4 GB of swap in use.

The fix for a kill is a memory budget: refuse a load that won't fit. Getting the budget right was harder than any crash. We reverted five of our own memory gates in two weeks. One estimate let an image model through that then crashed a 6 GB iPhone 15. Another, measured after freeing memory, refused loads that would have fit.

The red herrings

Not every crash is yours. One SIGSEGV in libgui had no app frame at all: a system bug on one maker's Android 12, and we left it alone. TextLayoutManager (13%) and dispatchDraw (4.3%) are still on our list, waiting for a reproduction. Without one, a fix is a guess.

"remarkably slow and stutters even with plenty of ram and small models."

App Store review, mirrored as GitHub issue #486 · July

What we are still figuring out

The LiteRT teardown is the big one: proving or killing the tool-resend hypothesis, and making teardown wait for the library's native thread. Streaming still re-parses the growing message. And the hardest question isn't technical: how to see crashes clearly without sending anything off the phone.

What we took away