FetchCompleted firing twice?

After learning about Remote Config at Dev Day LA today, I’m integrating it into my current project.

After some initial confusion between Remote Config and the very-similar-but-deprecated Remote Settings, I’ve got it working, however when I run it the FetchCompleted callback is getting called twice; once with empty data before my ConfigManager.FetchConfigs call, and once with all the expected data as a result of that call.

Where is that extra call coming from, and can I kill it so I don’t get that empty data?

Hey @luvcraft

is the first call coming back with remote? If so, are you doing on Awake? My guess is that the first call is for the legacy Remote Settings (games by default will do this). I can investigate further once I’m back in the office on Tuesday.

If that’s the issue, we’re hoping it’ll be resolved in a future package version where we decouple from the engine APIs for Remote Settings and Remote Config.

I had my call in Start rather than Awake because I wanted to make sure some things initialized in their own Awakes before it fired. If I move it to Awake then I still get two calls, but the first is cached and the second is remote, and I don’t see that blank data callback. Not sure why that fixes it?

Thanks for the quick reply! And the great talk!

1 Like

tried a bunch of different combinations, and here’s what I found:

FetchCompleted += ApplyRemoteSettings in Awake, nothing else:
= Cached callback, then blank Remote callback

FetchCompleted += ApplyRemoteSettings in Start, nothing else:
= Blank Remote callback

FetchCompleted += ApplyRemoteSettings and FetchConfigs in Awake:
= Cached callback, then Remote callback with correct values

FetchCompleted += ApplyRemoteSettings and FetchConfigs in Start:
= blank Remote callback, then Remote callback with correct values

FetchCompleted += ApplyRemoteSettings in Awake, FetchConfigs in Start:
= Cached callback, then blank Remote callback, then correct Remote callback!

FetchCompleted += ApplyRemoteSettings in Start, FetchConfigs in Awake:
= Just one Remote callback with correct values! (WUT)

I want to confirm that you are using the code here Code integration | Remote Config | 1.0.9 ? Can you elaborate what you mean by “cached callback” and “blank remote callback”

yeah, I’m using ApplyRemoteSettings code that’s identical to what’s in that example (except with my values instead of those provided). “cached callback” = ApplyRemoveSettings with ConfigOrigin.Cached, and “blank remote callback” = ApplyRemoveSettings with ConfigOrigin.Remote, but all the values in ConfigManager.appConfig are blank.

1 Like

Okay so did some investigation on our end, and this seems to be due to the in-engine APIs we’re using currently. They’re also used by the older Remote Settings system. We’ll be shipping a new version of the package in the next month or so that de-couples completely from the engine APIs that’ll solve the weirdness with these call orderings.

I guess in the meantime, were you able to get things working? If not, I’m more than happy to hop on a call with you and see what’s going on.

yay! a fix!

yep, I was able to get it working via that weird configuration I mentioned at the end of my investigations above, which I’ll un-weird once the fix arrives.

Thanks for the quick replies and for looking into this!

Now I need to track down the “Input System Rambod” for my current Input System woes… :slight_smile:

2 Likes

@luvcraft yay! I’m glad :slight_smile:

I’ll keep you posted on when the new release is ready!

Good luck on finding more Rambods, let me know if this Rambod can be of more help!

1 Like

Hi, i have the same issue, copy/paste code from documents page, then duplicate fetching happen

5185445--515132--remote-config-bug.PNG

// Retrieve and apply the current key-value pairs from the service on Awake:
    void Awake () {
        // Add a listener to apply settings when successfully retrieved:
        ConfigManager.FetchCompleted += ApplyRemoteSettings;

        // Fetch configuration setting from the remote service:
        ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    }

    void ApplyRemoteSettings (ConfigResponse configResponse) {
        // Conditionally update settings, depending on the response's origin:
        switch (configResponse.requestOrigin) {
            case ConfigOrigin.Default:
                Debug.Log ("Load fail! Use DEFAULT");
                break;
            case ConfigOrigin.Cached:
                Debug.Log ("Load fail! Use Cached");
                break;
            case ConfigOrigin.Remote:
                Debug.Log ("Success Load Settings From Server!");
                break;
        }
    }

Btw: I think it is still working without any problem, cause it’s still load success on 2nd.

1 Like

@dohaiha930 thanks for sharing that as well! Glad the double fetch is consistently reproducible, and that it’s not blocking you from proceeding.

1 Like

@rambod : On last version 1.0.8, this bug still be there, please fix it, because when it’s duplicate my handle methods.

@Jumeuan and @dohaiha930 this should now be fixed as of 1.1.0-preview. Let me know if you see it again after moving to a new version

1 Like

Just saying, the latest verified version for 2019.4 is still version 1.0.9, which has the double callback.

Make sure you select Show preview packages from the Advanced dropdown in the Package Manager UI. The latest I see as of today is 2.0.1 published Dec 12, I’m using Unity 2019.4.1f1

Pointed out because the verified versions tend to be much more safer and I want to add this feature to a released game. As much as the new version may work on my side/testers side, I don’t know every little details in the package that may bring harm in different scenarios, as much as the developers who wrote it.

2 Likes

still same issue. im getting called 2 times in latest unity 2020.3 version with FetchCompleted calling 2 times.unity please fix this.remote config version 2.1.2

Please test with version 3.0.0-pre.9 and share the code that you are using, we will check.

sure i will check and get back