Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Caching Issue Leading to ANR in Production #145

Closed
zura-adod opened this issue Oct 7, 2024 · 8 comments
Closed

Caching Issue Leading to ANR in Production #145

zura-adod opened this issue Oct 7, 2024 · 8 comments

Comments

@zura-adod
Copy link

I would like to report a caching issue I've encountered. While I haven't been able to reproduce the exact scenario, I have observed crashes in my production app, as detailed in the attached crash report. I'm not sure if this is related to a version mismatch or a known issue.

Here are the SDK versions we're using:

growthbook = "1.1.60"
growthbookNetworkDispatcher = "1.0.2"
The crash appears to be related to the following:

[com.sdk.growthbook.sandbox.CachingAndroid.getContent
ANR triggered by slow operations on the main thread:

kotlinx.serialization.json.Json.decodeFromString (Json.kt:100)
com.sdk.growthbook.sandbox.CachingAndroid.getContent (KMMCaching.kt:61)
com.sdk.growthbook.sandbox.KMMCachingKt.getData (KMMCaching.kt:23)
com.sdk.growthbook.features.FeaturesViewModel.fetchFeatures (FeaturesViewModel.kt:44)
com.sdk.growthbook.features.FeaturesViewModel.fetchFeatures$default (FeaturesViewModel.kt:41)
com.sdk.growthbook.GrowthBookSDK.refreshCache (GrowthBookSDK.kt:81)
com.space.toolkits.feature.toggle.provider.impl.SPFeatureToggleImpl$startPeriodicCacheRefresh$1.invokeSuspend (SPFeatureToggleImpl.kt:151)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)](url)

Could anyone assist in identifying a possible fix or let me know if I might be missing something in my configuration?

Thank you for your help!

@Bohdan-Kim
Copy link
Collaborator

Is SPFeatureToggleImpl#startPeriodicCacheRefresh() method from your application?

@nikantro888
Copy link

Yes, it's our method where we have written these lines of code:

  private fun startPeriodicCacheRefresh() {
        cacheRefreshJob = refreshCoroutineScope.launch(coroutineDispatchers.immediate) {
            while (isActive) {
                gb.refreshCache()
                // Call gb?.refreshCache() every 60 seconds
                delay(cacheRefreshInterval)
            }
        }
    }

@vazarkevych
Copy link
Collaborator

vazarkevych commented Oct 9, 2024

Hi, @nikantro888. We will check that and write to you.

@Bohdan-Kim
Copy link
Collaborator

Bohdan-Kim commented Oct 9, 2024

try to wrap calling gb.refreshCache() with Dispatchers.IO

@zura-adod
Copy link
Author

@Bohdan-Kim thanks for your response. We will try this approach in our next release and get back to you with the results.

@vazarkevych
Copy link
Collaborator

Hi, @zura-adod. Thank you, we will wait for that.

@vazarkevych
Copy link
Collaborator

Hi, @zura-adod. Did you try that?

@vazarkevych
Copy link
Collaborator

vazarkevych commented Nov 18, 2024

Hi, here is solution for that PR. After merge it will be availiable.

vazarkevych added a commit that referenced this issue Nov 20, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants