Closed apoyan-a closed 2 months ago
@apoyan-a , could you provide code snippets for your LDConfig as well as the region of code that calls LDClient.init?
Do you have any attributes in the context that change periodically or could be different between app launches?
What do you use for the context key?
Are the values you use for the context keys stable?
First, when the app is opened, ldclient.boolVariation(flagName, false) returns false. However after the FeatureFlagChangeListener triggers, ldClient.boolVariation(flagName, false) returns true. This leads to the user seeing two different states in the app.
Is this during first launch after fresh install, or every time the app is opened?
Second, when the app is in the background for a long time and the System kills the process, upon reopening the app, ldclient.boolVariation(flagName, false) always returns false. To avoid waiting for the System, I have reproduced this case simply by following adb command adb shell am kill app_package_name
With proper initialization, this should be providing the same flag value from the local cache that was fetched previously. This leads me to believe we should investigate the initialization routine and the context object being used.
Thanks for the quick response.
Here is how I create the LDConfig
LDConfig.Builder(LDConfig.Builder.AutoEnvAttributes.Enabled)
.mobileKey(key)
.events(
Components.sendEvents().allAttributesPrivate(true)
)
.build()
and here is the LDClient.init
LDClient.init(application, ldConfig, ldContext, 0)
To pass context to LDClient.init I create the context only with the key. Then I call ldClient.identify(context)
and here the context contains full data.
It seems I understand the first issue. I call ldClient.identify a bit late, and after that call, the FeatureFlagChangeListener gets triggered.
Is this during first launch after fresh install, or every time the app is opened?
Every time the app is opened.
With proper initialization, this should be providing the same flag value from the local cache that was fetched previously. >This leads me to believe we should investigate the initialization routine and the context object being used.
After you asked about context I've checked, and it turns out I don't call
ldClient.identify(context)
, and that's why LaunchDarkly didn't return right value.
I think you don't have anything to check, both cases need to be fixed on my side. Thanks for the clue.
No worries! I'm going to close this issue for now and if you do uncover something you can re-open it.
Thank you for using LaunchDarkly!
Hi LaunchDarkly Team,
When we set semantic version check from the dashboard, in some cases LaunchDarkly returns the wrong boolean value. We have two cases. •First, when the app is opened,
ldclient.boolVariation(flagName, false)
returns false. However after theFeatureFlagChangeListener
triggers,ldClient.boolVariation(flagName, false)
returns true. This leads to the user seeing two different states in the app. •Second, when the app is in the background for a long time and the System kills the process, upon reopening the app,ldclient.boolVariation(flagName, false)
always returns false. To avoid waiting for the System, I have reproduced this case simply by following adb commandadb shell am kill app_package_name
Additional details Launch Darkly version - 5.2.0 OS Android 13 device - I have tried Samsung A33, pixel 6 emulator
Let me know if any other information is needed.