braze-inc / braze-android-sdk

https://www.braze.com
Other
20 stars 9 forks source link

[Bug]: Unexpected high latency when fetching content cards after several times #36

Closed lbillaud-bbc closed 1 month ago

lbillaud-bbc commented 2 months ago

Braze Android SDK Version

31.1.0

Steps To Reproduce

Using this datasource fetching the content cards to be displayed in a custom recycler view alongside other messages, call getBrazeEvents multiple times in a short delay.

class BrazeContentCardsDataSource @Inject constructor(private val brazeInstanceProvider: BrazeInstanceProvider) {

    suspend fun getBrazeEvents(): ContentCardsUpdatedEvent = withContext(Dispatchers.IO) {
        suspendCoroutine { cont ->
            brazeInstanceProvider.braze?.let { braze ->
                val errorListener = object : IEventSubscriber<BrazeNetworkFailureEvent> {
                    override fun trigger(message: BrazeNetworkFailureEvent) {
                        cont.resumeWithException(BrazeNetworkFailedException())
                        braze.removeSingleSubscription(this, BrazeNetworkFailureEvent::class.java)
                    }
                }
                braze.subscribeToNetworkFailures(errorListener)
                braze.subscribeToContentCardsUpdates(object : IFireOnceEventSubscriber<ContentCardsUpdatedEvent> {
                    override fun trigger(event: ContentCardsUpdatedEvent) {
                        cont.resume(event)
                        braze.removeSingleSubscription(this, ContentCardsUpdatedEvent::class.java)
                        braze.removeSingleSubscription(errorListener, BrazeNetworkFailureEvent::class.java)
                    }
                })
                braze.requestContentCardsRefresh()
            } ?: cont.resumeWithException(BrazeNotActivatedException())
        }
    }

Expected Behavior

We expect the SDK to return a ContentCardsUpdatedEvent quickly and efficiently with each call

Actual Incorrect Behavior

We noticed some calls taking a very long time to answer (from 10s to more than 2 minutes)

image

Verbose Logs

No response

Additional Information

No response

bryanlogan commented 2 months ago

Can you provide full logs? I'm wondering if you're being throttled here.

lbillaud-bbc commented 2 months ago

Hello Bryan unfortunately I can't provide more meaningful logs as they provide critical data. I came across this warning though image

I guess it fits pretty well the use case. WDYT?

radixdev commented 1 month ago

Hi @lbillaud-bbc ,

Please email support@braze.com with those content card logs if you cannot provide them here.

And that second screenshot is indicative of a faulty integration where the api key was not supplied. I'd recommend putting it in your braze.xml file.