Reputation: 19737
When I attempt to post a high score to Facebook with the code below, I receive this error:
Invalid indirect reference 0x12341234 in decodeIndirectRef
The error happens when the request is executed.
Bundle params = new Bundle();
params.putString("score", "123");
Request postScoreRequest = new Request(session,
"/me/scores",
params,
HttpMethod.POST,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Log.d("test", "error: " + error);
} else {
Log.d("test", "success");
}
}
});
postScoreRequest.executeAsync();
The above Java code is called from C++ via JNI. I have many similar C++ to Java JNI methods that work fine. I tried running the above high score submission code when the user first logs in to Facebook (so no JNI involved) and I didn't see the crash.
Why does calling the above code via JNI cause the error?
Edit: I noticed this crash happens at the next JNI call from C++ to Java. It can be totally unrelated to high scores. If I comment postScoreRequest.executeAsync()
then the crash goes away. I'm trying to figure out how that line is affecting the JNI.
Edit: explicitly creating and executing the request on the UI thread works. I still want to understand why this is the case.
Upvotes: 2
Views: 115
Reputation: 5266
Assuming your C++ code runs on a different thread than the UI Thread (Because it's a game -> probably OpenGL -> Gl renderer starts it own thread): Your Java thread is also not on the UI thread and Facebook's executeAsync
should be ran on the UI thread:
https://developers.facebook.com/docs/reference/android/3.0/class/Request/#executeAsync%28%29
executeAsync() Executes this request and returns the response. This should only be called from the UI thread.
P.S. To fix it, I would call runOnUiThread
Upvotes: 1