Skip to content

fix: replace eventCache LruCache with ConcurrentHashMap#307

Merged
barrydeen merged 1 commit into
mainfrom
fix/event-cache-lru-eviction
Mar 24, 2026
Merged

fix: replace eventCache LruCache with ConcurrentHashMap#307
barrydeen merged 1 commit into
mainfrom
fix/event-cache-lru-eviction

Conversation

@barrydeen
Copy link
Copy Markdown
Owner

Summary

  • Replace eventCache: LruCache<String, NostrEvent>(15000) with ConcurrentHashMap<String, NostrEvent>() to eliminate silent eviction of events
  • Add ObjectBox fallback in getEvent() so cross-session lookups resolve from the database when not in memory
  • Remove two oversized vector drawables (image2vector.xml, ic_launcher_foreground.xml) with 130KB+ path data strings that caused AAPT2 STRING_TOO_LARGE build failures; switch splash screen icon to splash_icon.xml

Why

LruCache(15000) evicted events under session pressure. Any code calling getEvent(id) after eviction got null — causing orphaned notes in thread view, blank quote embeds, and empty thread views on tap. The events existed in ObjectBox but the cache never fell back to query them.

ConcurrentHashMap has no eviction cap so events stay available for the session lifetime. Memory scales with actual usage (~2k–10k events typical) rather than a fixed 15k ceiling. clearAll() / clearFeed() still wipe it on logout or feed switch.

Test plan

  • Scroll feed past a large number of notes, then tap an early note → thread should load correctly
  • View a post with a quoted note → embed should resolve
  • Navigate to a thread with a parent note seen earlier in the session → parent appears
  • Build succeeds without STRING_TOO_LARGE errors
  • Splash screen still shows flame icon

…iction bugs

LruCache(15000) was silently evicting events under pressure, causing orphaned
notes in threads, broken quote embeds, and empty thread views on tap. Replace
with ConcurrentHashMap (no eviction cap) and add an ObjectBox fallback in
getEvent() for cross-session lookups. Also remove two oversized vector drawables
(130KB+ pathData strings) that caused AAPT2 STRING_TOO_LARGE build failures.
@barrydeen barrydeen merged commit c43eedd into main Mar 24, 2026
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