Why doesn't FirebaseRemoteConfig.fetch call a callback?

Background

I am trying to use the new Google Firebase services to test A / B. To do this, we need to use Firebase Analytics and Firebase RemoteConfig.

Problem

Using FireBase RemoteConfig, I wanted to get variables from the server (which have different meanings for each variant of each experiment), but it seems that on some devices it gets stuck there without calling its callback (OnCompleteListener.onComplete).

I used approximately the same code as for the samples ( here ):

// init: boolean isDebug = ... ; mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(isDebug).build(); mFirebaseRemoteConfig.setConfigSettings(configSettings); final HashMap<String, Object> defaults = new HashMap<>(); for (...) defaults.put(...); mFirebaseRemoteConfig.setDefaults(defaults); //fetching the variables: long cacheExpiration = isDebug ? 0 : java.util.concurrent.TimeUnit.HOURS.toSeconds(1); mFirebaseRemoteConfig.fetch(cacheExpiration).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { //on some devices, I never get here at all if (task.isSuccessful()) { mFirebaseRemoteConfig.activateFetched(); final FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(context); for (...) { String experimentVariantValue = mFirebaseRemoteConfig.getString(...); firebaseAnalytics.setUserProperty(..., experimentVariantValue); } } else { } } }); 

The thing is, the callback is not called, but only on some devices:

  • Nexus 5 with Android 6.0.1: almost always succeeds.
  • Nexus 4 with Android 5.1.1 and LG G2 with Android 4.2.2: almost always freezes (which means they don't fall into the callback)

I also found that when it works, it works in the coming sessions later.

Question

Why is this happening? What can I do to solve this problem?

+7
android firebase firebase-remote-config
source share
3 answers

To add to what Cachapa just posted, an error occurs when fetch () is called too early. We found two solutions to the problem (both of them work, but are not satisfactory) - call the fetch () function from onResume or add a delay of 3 seconds until the actual fetch () is returned.

And that โ€œit works in the next sessions afterwardsโ€, after you get the callback and call the activateFetched () function, all sessions will get the correct values.

An update of a 3 second delay was caused by Activity.onCreate (). After checking, he worked on only one device - Nexus 4. He did not do the trick on the Samsung S3 or on the Moto X Pure. We also checked the Samsung S7, where it worked without delay - the problem never manifested itself at all.

We discuss it in Firebase-enabled mail. I will clarify here when they will return to me.

Update 2 The Firebase team claims that this is allowed in GPSv9.4, and I think they are right this time. They also claimed that this was resolved in 9.3, but then my tests disproved it. Now (after updating our gms dependency to v9.4), I correctly receive callbacks on my dev devices. However, I still get directions that not all of our production devices get the correct configuration. I believe that devices that have not updated GPS to the latest version are still erroneous, but I'm not sure.

+1
source share

There seems to be some kind of race condition in the Firebase initialization code, according to this answer: fooobar.com/questions/220488 / ...

I tried quite a few overlaid workarounds, and nothing worked reliably enough for my satisfaction. It seems that Firebase developers are aware of this problem, so the problem will be fixed soon.

0
source share

Why is this happening? What can I do to solve this problem?

I guess the reason why the calling calls are not being called because the FireBase Remote Config may have several problems and they have not yet been resolved.

Below is a list of things that my team and I have found so far that might be considered remote configuration problems.

Listed below are some Remote Config related problems that my teammates and I have found so far. The first two of them are related to Google Search, and the last one is: "Build and build Debug build can affect the behavior of Remote Config ..?" from our observation after testing Remote Config for a while, so we are not sure about this yet.

I'm not sure if this solves your problem, but if your problem is related to the first problem of what I listed above, because fetch() is called too early, you can try calling fetch() using postDelayed , which we tried, and he had a great chance that Remote Config would succeed in summoning his listeners, but in my personal opinion, Remote Config was simply not completely ready for production. .

0
source share

All Articles