Skip to content

fix: compute spam score off-lock to prevent input-dispatch ANR#590

Open
Letdown2491 wants to merge 1 commit into
barrydeen:mainfrom
Letdown2491:fix/spam-score-anr
Open

fix: compute spam score off-lock to prevent input-dispatch ANR#590
Letdown2491 wants to merge 1 commit into
barrydeen:mainfrom
Letdown2491:fix/spam-score-anr

Conversation

@Letdown2491

Copy link
Copy Markdown
Contributor

NotificationRepository.addEvent ran NSpamClassifier.score() inside synchronized(lock) via mergeKind1 -> mergeReply. Feature extraction runs several regex passes over up to ten notes per author; doing it under the lock stalls every caller -- including main-thread callers like getAllPostCardEventIds() and markRead -- past the 5s input-dispatch deadline.

Fix: warmSpamScore(event) runs before the lock, computes the score under the same spamFilterEnabled/isFollowing/safelist/reply-target guards, and caches it in SpamAuthorCache (LruCache-backed, thread- safe). mergeReply now only consults the cache.

Port of barrydeen/dark-wisp-android#23.

NotificationRepository.addEvent ran NSpamClassifier.score() inside
synchronized(lock) via mergeKind1 -> mergeReply. Feature extraction
runs several regex passes over up to ten notes per author; doing it
under the lock stalls every caller -- including main-thread callers
like getAllPostCardEventIds() and markRead -- past the 5s
input-dispatch deadline.

Fix: warmSpamScore(event) runs before the lock, computes the score
under the same spamFilterEnabled/isFollowing/safelist/reply-target
guards, and caches it in SpamAuthorCache (LruCache-backed, thread-
safe). mergeReply now only consults the cache.

Port of barrydeen/dark-wisp-android#23.
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