Get_signed_player_info freezes the app

Hello,

I am creating a Facebook Instant game and I am currently in the process of implementing Playfab. Eventually I would like to use “LoginWithFacebookInstantGamesId” of the playfab library but to get there I need the signed info via the “get_signed_player_info” method of the fbinstant library.

When I test everything inside the editor then it almost works, except that I get an error from Playfab, telling me that the signature is incorrect, even though everything seems to be set up correctly. So I figured that maybe it’s because I need to test the game live in browser after uploading to the fb app dashboard.

However, the issue seems to be that whenever I call get_signed_player_info the app freezes in the browser. I just see a black screen because the next scene is not loaded.
After I remove that code block then it runs fine.
This is the code:

And this is the result in the browser:



Defold version:
image

extension-fbinstant version 7.0.0.

What could be the issue here?

Thanks!

In the document it says the first argument should be a string, which is also the case when looking at the code:

What if you pass in a string as the first argument?

I figured this could be nil instead because according to the FB SDK the string can be null:

Well, that might be true, but this is our function, and as I showed you, it expects a string :slight_smile:

Okay, I will try an empty string.

Two questions though:

  1. Why not make it the same as the fb sdk expects? This way such confusion would not be created.
  2. Why not return/log an error when invalid input was received in your function? If I had a clear error message telling me it expected a string and nothing else, I would not have created this forum post (assuming that it works with an empty string).
  1. I don’t actually know why it was done this way. We’ll ask @britzl
  2. This is not done intentionally. I think the error is hidden somewhere in the nested callbacks.

It would be absolutely great if the APIs were a 100% match. But Facebook does not provide a structured API spec that could be used to generate the bindings from JS to Lua which means that each function binding has to be created by hand.

In our documentation we say that “The extension provides an almost 1 to 1 mapping between the Javascript SDK and the Lua API.” We never promise an exact match, only something closely resembling the JS API.

By the way, this is a perfect opportunity to make a code contribution! I would recommend that you create a utility function in fbinstant.cpp that looks like this:

static const char* checkstring(lua_State* L, int index, const char* default_value)
{
    return lua_isstring(L, index) ? luaL_checkstring(L, index) : default_value;
}

This will return the string at the specific index in the Lua stack or the provided default value if there was no string at the specified index.

Next you change the function in question to use the new function. Like so:

static int FBInstant_GetSignedPlayerInfoAsync(lua_State* L) {
	int top = lua_gettop(L);

	const char* requestPayload = checkstring(L, 1, "");  // <--- USING THE NEW FUNCTION!
	luaL_checklistener(L, 2, getSignedPlayerInfoAsyncListener);
	FBInstant_PlatformGetSignedPlayerInfoAsync((OnSignedPlayerInfoCallback)FBInstant_OnSignedPlayerInfo, requestPayload);

	assert(top == lua_gettop(L));
	return 0;
}

The code (luaL_checkstring) will generate a Lua error with a callstack if the value isn’t a string. Are you running the code from within a coroutine or inside a pcall()? If that is the case the error will not be visible in the console unless you manually catch and log it.

3 Likes