I have some code which loads the user profile picture from Facebook using the Facebook SDK.
private void GetProfilePicture(string userId)
{
FB.API(userId + "/picture?width=256&height=256", HttpMethod.GET, OnGetProfilePicture);
}
private void OnGetProfilePicture(IGraphResult result)
{
Debug.Log(result.RawResult);
if (result.Error == null) // Success
{
Texture2D texture = result.Texture;
texture.name = "ProfilePicture";
DispatchResponse(SocialServiceResult.SUCCESS, texture);
}
else // Failure
{
DispatchResponse(SocialServiceResult.FAILURE, null);
}
}
The exact same codebase used to work perfectly fine in the previous version of Unity i.e. 5.6.2. I have tested the codebase both on the editor and the device (Android) but the issue remains. Just for reference here is what I get on the editor console on logging failure:
Unable to get the profile picture. SocialServiceResult: FAILURE
UnityEngine.Debug:LogWarning(Object)
TurboLabz.Gamebet.Logger:LogWarning(Object) (at Assets/Common/Scripts/Utils/Static/Logger.cs:39)
TurboLabz.Gamebet.GetPlayerProfilePictureCommand:OnGetProfilePicture(SocialServiceResult,
Texture2D) (at Assets/Gamebet/Scripts/Controllers/GetPlayerProfilePictureCommand.cs:61)
strange.extensions.promise.impl.Promise`2:CallListener() (at Assets/Strange/extensions/promise/impl/Promise.cs:205)
strange.extensions.promise.impl.Promise`2:Dispatch(SocialServiceResult, Texture2D) (at Assets/Strange/extensions/promise/impl/Promise.cs:165)
TurboLabz.Gamebet.FBGetProfilePictureRequest:DispatchResponse(SocialServiceResult, Texture2D) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:104)
TurboLabz.Gamebet.FBGetProfilePictureRequest:OnGetProfilePicture(IGraphResult) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:98)
Facebook.Unity.<Start>d__9:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
I also checked the values of the different variables. The value of result.Error
is an empty string; it is not null. The value of result.Texture
is null. On logging the value of result.RawResult
the editor console shows:
����
UnityEngine.Debug:Log(Object)
TurboLabz.Gamebet.Logger:Log(Object) (at Assets/Common/Scripts/Utils/Static/Logger.cs:29)
TurboLabz.Gamebet.FBGetProfilePictureRequest:OnGetProfilePicture(IGraphResult) (at Assets/Gamebet/Scripts/Services/Facebook/FBRequests/FBGetProfilePictureRequest.cs:99)
Facebook.Unity.<Start>c__Iterator0:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
That looks like some garbage value inside result.RawResult
.
Another thing worth mentioning is that I can log into my game perfectly fine with using Facebook SDK; no issues there. It’s just the profile picture that has become an issue.
This problem started occurring after upgrading Unity to 2017.1.0f3 (64bit) on the very same codebase that I had earlier. I am running Unity on macOS Sierra. Facebook SDK version is 7.9.4 (I also upgraded to Facebook SDK version 7.10.0 but no luck).
Does anybody have any idea what could be the problem? Or is it a bug in Unity/Facebook SDK?
Thanks in advance.