-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Don't retry IAM display if 410 is received from backend #2158
Conversation
- Changed `messages` from an immutable list to a mutable list
d4b4fce
to
1896f10
Compare
- Added synchronization to `makeRedisplayMessagesAvailableWithTriggers` and `attemptToShowInAppMessage` to prevent concurrent modification issues - Refactored `evaluateInAppMessages` to collect messages for display inside a synchronized block and process them outside to avoid suspension points within critical sections
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the change works and I am no longer getting repeating 410 errors. Nice work!
@@ -106,6 +106,8 @@ internal class InAppMessagesManager( | |||
private val fetchIAMMutex = Mutex() | |||
private var lastTimeFetchedIAMs: Long? = null | |||
|
|||
private val lock = Any() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this lock is only for synchronizing 'messages'. In this case we can just call 'synchronized(messages)' instead of introducing a temp lock instance.
- Changed `synchronized(lock)` to `synchronized(messages)`
Description
One Line Summary
Don't retry IAM display if 410 is received from backend
Details
Motivation
In instances where an IAM is disabled mid-session, a 410 is received and is caught in a retrying loop. This change will prevent the retry and just not display the IAM, since it just become disabled.
Scope
Changes to
InAppMessagesManager
only.Since this change involves changing the
messages
list, synchronization was added tomakeRedisplayMessagesAvailableWithTriggers
andattemptToShowInAppMessage
to prevent concurrent modification issues.evaluateInAppMessages
was further updated to collect messages for display inside a synchronized block and process them outside to avoid suspension points within critical sections.Testing
Manual testing
Forced reproduction by setting breakpoint right before IAM is set to display, pausing the IAM from the dashboard, then resuming app flow. A 410 will result.
After updating the code, tested on an Android 14 emulator to see that app resumes normally after IAM is paused in the dashboard. Subsequent 410s are not received and app resumes as expected.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is