Skip to content

Coder Agent: ## Task Investigate and fix the SUSPECTED bug described below. You are continuing the SAME session t - #32

Open
kai-by-gleap[bot] wants to merge 1 commit into
masterfrom
gleap-code/6a97521d7764b6f88ab7c48b-03ef4fdc-51dc-428f-97f9-712c2487e23f
Open

kai-by-gleap[bot] wants to merge 1 commit into
masterfrom
gleap-code/6a97521d7764b6f88ab7c48b-03ef4fdc-51dc-428f-97f9-712c2487e23f

Conversation

@kai-by-gleap

@kai-by-gleap kai-by-gleap Bot commented Sep 1, 2026

Copy link
Copy Markdown

Automated changes by Kai by Gleap.

Task: ## Task
Investigate and fix the SUSPECTED bug described below. You are continuing the SAME session that investigated it — you already know the hypothesis and the evidence.

VERIFY FIRST: Step 1 of your plan MUST verify the hypothesis against the code/data. If verification shows this is configuration or expected product behaviour — NOT a code bug — do not invent a code change: write .kai/plan.md starting with the exact line VERDICT: NOT_A_BUG, followed by the corrected explanation and a customer-ready answer. The platform routes that verdict back to the resolution flow.

Bug report

Opening a full-screen ad triggers Android onTrimMemory, which evicts Gleap's image cache; a cached bitmap was already recycled by GleapChatMessage, so sizeOf's getByteCount() throws IllegalStateException in the unguarded onTrimMemory callback, crashing the host app on the main thread.

Gleap's image loader keeps remote images in an in-memory cache and hands the cached image object straight to chat/news message views. Those message views later recycle the image when they are cleared, but the cache still holds the same image. When a full-screen ad opens, Android asks the app to free memory; Gleap's memory-trim callback then tries to empty the cache, and measuring a recycled image throws an error. Because the trim callback has no error handling, that error is uncaught on the app's main thread and kills the host app. The same code path is present in both the customer's 16.4.6 SDK and the current development source.

Internal evidence

  • Android-SDK/gleap/src/main/java/io/gleap/GleapImageLoader.java:50 — sizeOf calls bitmap.getByteCount(), which throws IllegalStateException on a recycled bitmap; called by LruCache during evictAll/trimToSize
  • Android-SDK/gleap/src/main/java/io/gleap/GleapImageLoader.java:244 — ComponentCallbacks2.onTrimMemory callback (R8 GleapImageLoader$4) calls cache.evictAll()/trimToSize with no try/catch, so an exception here is an uncaught main-thread crash
  • Android-SDK/gleap/src/main/java/io/gleap/GleapImageLoader.java:116 — background executor puts the decoded bitmap into the cache
  • Android-SDK/gleap/src/main/java/io/gleap/GleapImageLoader.java:138 — deliver() invokes imageLoaded with the same bitmap instance retained by the cache, sharing the reference with callers
  • Android-SDK/gleap/src/main/java/io/gleap/GleapChatMessage.java:94 — clearComponent() recycles avatarBitmap, which is the same instance GleapImageLoader.cache still holds
  • Android-SDK/gleap/src/main/java/io/gleap/GleapChatMessage.java:161 — GleapImageLoaded callback stores the delivered (cache-shared) bitmap into avatarBitmap

Investigate and fix the SUSPECTED bug described below. You are continuing the SAME session that investigated it — you already know the hypothesis and the evidence.

VERIFY FIRST: Step 1 of you
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.

0 participants