Search code examples
facebook-instant-games

Leaderboard strange behavior and issues


We have several issues with leaderboards:

1) our leaderboard is set as global. When I list all entries it in game, I get this:

enter image description here

Here is the same table, but readable better:

enter image description here

Table has 5 entries, but is missing ranks 1 and rank 5. First record is "Jiří" with rank 2. But, from FB pages I know there is person with rank 1 (Jamie Pichardo Garcia):

enter image description here

So, first question is, why this person is not listed in table?

2) calling getEntriesAsync has 2 parameters: number of entries to return and offset from top of the table. Here is table of results we get when calling getEntriesAsync(1, x), where x are numbers from 0 to 7:

enter image description here

Calling with offset 0 does not return any entry (should return "Jiří" as he is first in table?). Also calling with offset 4 returns nothing. In fact it looks it returns record with rank = offset + 1. If such rank is missing in table, it returns no entry (or rejects - see point 3))

So, second question is: is this intended behavior or bug? For offset 0, I would expect first entry in table, with offset 1 second entry ...

3) there is inconsistent behavior when no entry is found. On my PC and on many devices promise is resolved with empty array of entries. In Messenger on Android 4.4 the same promise is rejected (not speaking about other promise issues there). If we call getEntriesAsync() with higher count (like: return 2 entries), the promise is also rejected, if at least one of entries is not found (like calling getEntriesAsync(2, 4) on listed table) - it returns one entry on PC.

So, third question is: is it bug? Should promise always resolve with empty array? It surely shoud not reject if only one entry is missing...

4) Finally, what we wanted to achieve and what does not seem to work well. For player we wanted to get opponent, who is one position better in global leaderboard. Unfortuantely, you can accidently hit into skipped ranks and then no opponent is returned (or you even get promise rejection). For example if player is rank 6 ("Jirka" in table), we were asking for entry with offset 4 (4 = 6 - 1 - 1; -1 becuase ranks are 1...n, while offset 0...n-1 and -1 for one position better score). If called getEntriesAsync(1, 4), your promis either resolves with zero entries or rejects (Messenger + Android 4.4).

So, fourth question: is there any way how to get player one position better in global leaderboard?


Solution

  • Facebook is restricted from returning user information from activity that has not occurred in the last 90 days. Because of this, some scores from these users will be missing from the leaderboard.

    We are investigating ways to address this in the next SDK release.

    The promise rejections in point (3) are strange and we are investigating what is causing these. This API should be entirely consistent across platforms.

    To get the next player, you should be able to take the current rank and get the next X scores, returning the next non-null leaderboard entry.