Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentException when use FB.API in Unity 2021.1 #537

Open
5 tasks done
Velorth opened this issue Mar 25, 2021 · 50 comments
Open
5 tasks done

ArgumentException when use FB.API in Unity 2021.1 #537

Velorth opened this issue Mar 25, 2021 · 50 comments
Labels

Comments

@Velorth
Copy link

Velorth commented Mar 25, 2021

Checklist

Environment

Describe your dev environment here, giving as many details as possible. If you have them, make sure to include:

  • Unity Editor Version: 2021.1.0f1
  • Unity SDK Version: 9.0
  • Installation Platform & Verison: All platforms

Goals

I try to use FB.API to query user picture with GET request.

Expected Results

OnResult callback should be invoked in any case (success or error).

Actual Results

OnResult callback is never invoked.

Stack trace:

ArgumentException: Cannot create a data handler without payload data
UnityEngine.Networking.UploadHandlerRaw..ctor (System.Byte[] data) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequest/Public/UploadHandler/UploadHandler.bindings.cs:97)
UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Generic.Dictionary`2[TKey,TValue] headers) (at /Users/bokken/buildslave/unity/build/Modules/UnityWebRequestWWW/Public/WWW.cs:106)
Facebook.Unity.AsyncRequestString+<Start>d__9.MoveNext () (at <a252100d18af4907bfe50f230228e75e>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)

Steps to Reproduce

  1. Initialize Facebook SDK.
  2. Call API

Code Samples & Details

FB.API($"{_userId}/picture?type=normal", HttpMethod.GET, OnResult);
@Velorth Velorth added the bug label Mar 25, 2021
@Velorth
Copy link
Author

Velorth commented Mar 29, 2021

The issue is caused by legacy WWW class in Unity 2021. Upgrade to UnityWebRequest fixes the problem.

@byteflowY
Copy link

Same.

How can I upgrade to UnityWebRequest?

@Velorth
Copy link
Author

Velorth commented Mar 29, 2021

@JustKoTMurchik, you need to patch AsyncRequestString.Start() method and GraphResult class.
I'll try to create pull request soon.

@byteflowY
Copy link

@Velorth Thx!

@Thaina
Copy link

Thaina commented Apr 2, 2021

+1

3 similar comments
@binouze
Copy link

binouze commented Apr 13, 2021

+1

@lucas-brasmobi
Copy link

+1

@alexandrumaneaivfuture
Copy link

+1

@kerembaydogan
Copy link

Any update?

@samavan
Copy link

samavan commented Apr 26, 2021

Any fix?...
Nothing mentioned from the ChangeLog.. :(

@farahjr
Copy link

farahjr commented May 4, 2021

@JustKoTMurchik, you need to patch AsyncRequestString.Start() method and GraphResult class.
I'll try to create pull request soon.

What do You mean with "patch"? I would assume i need to compile some DLLs. Is that correct? I tried downloading develop branch, resolve dependency issues, build and replace every DLL of the SDK in my project. but didn't worked.

@kerembaydogan
Copy link

@Velorth I have tried to build both your forked dev branch and facebook-sdk-for-unity dev branch with your changes.
Both build failed.

Have you ever build your dev branch successfully?

@farahjr
Copy link

farahjr commented May 4, 2021

@Velorth I have tried to build both your forked dev branch and facebook-sdk-for-unity dev branch with your changes.
Both build failed.

Have you ever build your dev branch successfully?

I got success building them. THey just need some nuget references.

Every thing build fine here. But once i try to put the DLLs on my unit project there is no FB.Mobile.something in FB.Mobile. SO not sure what is happening.

@farahjr
Copy link

farahjr commented May 4, 2021

@Velorth I have tried to build both your forked dev branch and facebook-sdk-for-unity dev branch with your changes.
Both build failed.

Have you ever build your dev branch successfully?

image

I'm new to GitHub. What we can make for this to make a release ASAP?

@Velorth
Copy link
Author

Velorth commented May 5, 2021

@farahjr, dev branch looks a little bit outdated and it is not compatible with examples in master branch. So there isn't any public class in FB.Mobile and Graph API version is set to unsupported v3.0.
These changes should be applied to master branch, but according to the rules pullrequests should be made to dev branch.

@visualbruno
Copy link

Replace the code that has been done in https://github.com/facebook/facebook-sdk-for-unity/pull/539/files and compile the projet "Facebook.Unity"

Then replace the DLL in your Unity projet. It works.

Contact me if you want the DLL. I just built it right now using Unity 2021.1.5 DLLs and the login worked again.
Tested in Editor and Android. I don't know for IOS.

It is just a workaround until they do it.

@kerembaydogan
Copy link

With the help of @visualbruno, I have fixed the problem.

Facebook SDK team please fix this bug when you have time because this bug makes your SDK unusable with Unity 2021

@samavan
Copy link

samavan commented May 6, 2021

With the help of @visualbruno, I have fixed the problem.

Facebook SDK team please fix this bug when you have time because this bug makes your SDK unusable with Unity 2021

Yes please I am waiting also 🙏🙏

@snorrsi
Copy link

snorrsi commented May 6, 2021

The pull request that @Velorth created breaks the support for Unity less than 2017.1 .. that is bad because according to Facebook Unity SDK page they mention that it Requires Unity 5.4 and up.
It will not work with version 5.4 - 5.6 and 2017.1

If Facebook still wants to support 5.4 they can't accept that pull request unchanged.

@kerembaydogan
Copy link

@snorrsi The backward compatibility problem that you mentioned is easy to fix with Platform dependent compilation directives.

Starting from Unity 5.3.4, you can compile code selectively based on the earliest version of Unity required to compile or execute a given portion of code. Given the same version format as above (X.Y.Z), Unity exposes one global #define in the format UNITY_X_Y_OR_NEWER, that can be used for this purpose.

@farahjr
Copy link

farahjr commented May 6, 2021

@farahjr, dev branch looks a little bit outdated and it is not compatible with examples in master branch. So there isn't any public class in FB.Mobile and Graph API version is set to unsupported v3.0.
These changes should be applied to master branch, but according to the rules pullrequests should be made to dev branch.

That might explain my current problem. I got success integrating with Firebase and facebook at Editor runtime, but when building and deplying on my phone, i Got an oauth error:

2021/05/06 10:23:52.243 16976 21572 Error GraphResponse {HttpStatus: 400, errorCode: 200, subErrorCode: -1, errorType: OAuthException, errorMessage: An access token is required to request this resource.}

I will try fetching master and patching only the changes withing this commit.

@Velorth
Copy link
Author

Velorth commented May 6, 2021

@kerembaydogan, conditional compilation is not an option because there are lots of users that use Facebook SDK as a pre-built binary package. According to the Unity docs UnityWebRequest was introduced in Unity 5.4. I will check if it realy works and what can we do if it doesn't.

@kerembaydogan
Copy link

kerembaydogan commented May 6, 2021

@Velorth Yeah you are right, that wont work if they continue to release single sdk package.

Maybe they build/release multiple sdk packages from the same code base using directives and support both old and new unity versions?

BTW when unity removes UnityWebRequest they have to find a way.

@binouze
Copy link

binouze commented May 7, 2021

To get it working, I deleted the Facebook.Unity.dll file and replaced it by the Facebook.Unity source folder then corrected the errors in the C# code.
As usual thanks Facebook for never testing Unity SDKs ...

@samavan
Copy link

samavan commented May 9, 2021

Facebook.Unity

Could you tell a bit more where you found the new facebook.Unity.dll file ?
or what do you mean by "replaced it by the Facebook.Unity source folder"? ...
I am having the same issue for weeks... :(

image

@farahjr
Copy link

farahjr commented May 9, 2021

Facebook.Unity

Could you tell a bit more where you found the new facebook.Unity.dll file ?
or what do you mean by "replaced it by the Facebook.Unity source folder"? ...
I am having the same issue for weeks... :(

image

image

@binouze
Copy link

binouze commented May 10, 2021

Hi @samavan, In the FacebookSDK/Plugins folder, I just deleted the Facebook.Unity.dll file, then dropped the folder highlighted on your screenshot in that folder.

@samavan
Copy link

samavan commented May 10, 2021

Hi @samavan, In the FacebookSDK/Plugins folder, I just deleted the Facebook.Unity.dll file, then dropped the folder highlighted on your screenshot in that folder.

Hmm what I did but getting errors...
Also the Facebook menu disappeared... :(
Screen Shot 2564-05-10 at 12 19 03

@samavan
Copy link

samavan commented May 10, 2021

Screen Shot 2564-05-10 at 12 27 50
Finally managed to get the scripts to compile without error removing other dll replacing with the original directories.
However build compilation error on iOS platform.

@binouze
Copy link

binouze commented May 10, 2021

Sorry I forgot a step, you have to create an assembly definition for Facebook.Unity after adding the folder:

  1. Right click on Facebook.Unity folder -> Create -> Assembly Definition
  2. Rename it Facebook.Unity
    It should work

Screenshot 2021-05-10 100808

@samavan
Copy link

samavan commented May 10, 2021

Sorry I forgot a step, you have to create an assembly definition for Facebook.Unity after adding the folder:

  1. Right click on Facebook.Unity folder -> Create -> Assembly Definition
  2. Rename it Facebook.Unity
    It should work

Thanks! Worked a charm! Project compiles fine :)

And then also project builds fine after re-opening every single scenes from the Examples directory as mentioned the error logs here : #552

@samavan
Copy link

samavan commented May 10, 2021

However after compiling on device :

  1. press FB.Init
  2. press Classic Login
  3. press Graph Request
  4. press Basic request - Me >> give error log from Xcode as below
    Screen Shot 2564-05-10 at 16 01 40

Any idea? O_o...

@binouze
Copy link

binouze commented May 10, 2021

Did you replace WWW by UnityWebRequest ?
You can find what to change here: https://github.com/facebook/facebook-sdk-for-unity/pull/539/files thanks to @Velorth

@farahjr
Copy link

farahjr commented May 10, 2021

However after compiling on device :

  1. press FB.Init
  2. press Classic Login
  3. press Graph Request
  4. press Basic request - Me >> give error log from Xcode as below
    Screen Shot 2564-05-10 at 16 01 40

Any idea? O_o...

Just open the file above and apply the changes. Then recompile, get the dll and replace over your project..

@samavan
Copy link

samavan commented May 12, 2021

@binouze @farahjr now working a charm, thanks for the fast support! ;)

@indra452
Copy link

Replace the code that has been done in https://github.com/facebook/facebook-sdk-for-unity/pull/539/files and compile the projet "Facebook.Unity"

Then replace the DLL in your Unity projet. It works.

Contact me if you want the DLL. I just built it right now using Unity 2021.1.5 DLLs and the login worked again.
Tested in Editor and Android. I don't know for IOS.

It is just a workaround until they do it.

Hi i need DLL. Please share it

@visualbruno
Copy link

visualbruno commented May 17, 2021 via email

@indra452
Copy link

Hi You can download them here : https://www.dropbox.com/sh/rh1r4vbevpcmq55/AAAlqW7biGD0fMQUhNzXI1B3a?dl=0 I compiled them using Unity 2021.1.5. Regards Bruno Provenance : Courrierhttps://go.microsoft.com/fwlink/?LinkId=550986 pour Windows 10 De : Indra Kumar @.> Envoyé le :lundi, 17 mai 2021 17:29 À : @.> Cc : Bruno @.>; @.> Objet :Re: [facebook/facebook-sdk-for-unity] ArgumentException when use FB.API in Unity 2021.1 (#537) Replace the code that has been done in https://github.com/facebook/facebook-sdk-for-unity/pull/539/files and compile the projet "Facebook.Unity" Then replace the DLL in your Unity projet. It works. Contact me if you want the DLL. I just built it right now using Unity 2021.1.5 DLLs and the login worked again. Tested in Editor and Android. I don't know for IOS. It is just a workaround until they do it. Hi i need DLL. Please share it — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#537 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAC7CQHYS6INJVZWF3ZW5MDTOEY7HANCNFSM4ZZTHDZQ.

Thank you working fine!

@psonichicmic
Copy link

Hi You can download them here : https://www.dropbox.com/sh/rh1r4vbevpcmq55/AAAlqW7biGD0fMQUhNzXI1B3a?dl=0 I compiled them using Unity 2021.1.5. Regards Bruno Provenance : Courrierhttps://go.microsoft.com/fwlink/?LinkId=550986 pour Windows 10 De : Indra Kumar @.> Envoyé le :lundi, 17 mai 2021 17:29 À : @.> Cc : Bruno @.>; @.> Objet :Re: [facebook/facebook-sdk-for-unity] ArgumentException when use FB.API in Unity 2021.1 (#537) Replace the code that has been done in https://github.com/facebook/facebook-sdk-for-unity/pull/539/files and compile the projet "Facebook.Unity" Then replace the DLL in your Unity projet. It works. Contact me if you want the DLL. I just built it right now using Unity 2021.1.5 DLLs and the login worked again. Tested in Editor and Android. I don't know for IOS. It is just a workaround until they do it. Hi i need DLL. Please share it — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub<#537 (comment)>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAC7CQHYS6INJVZWF3ZW5MDTOEY7HANCNFSM4ZZTHDZQ.

Thanks its Working Fine :)

@wingsmight
Copy link

Thanks, it solved my issue with FB sign-in, but share function doesn't return anything (just FacebookDelegate isn't called). Anyone with the same?

@pacolaf
Copy link

pacolaf commented Jun 11, 2021

New version of Facebook SDK for Unity released just a few days ago (v11.0.0) and the issue hasn't been solved. Tested with Unity 2021.1.11f1.

@visualbruno
Copy link

I built the DLLs for Facebook SDK v11.0 @pacolaf
You can download them here: https://www.dropbox.com/sh/rh1r4vbevpcmq55/AAAlqW7biGD0fMQUhNzXI1B3a?dl=0
I don't use "share" function. Can you test it again @wingsmight ?

@wingsmight
Copy link

wingsmight commented Jun 11, 2021

I built the DLLs for Facebook SDK v11.0 @pacolaf
You can download them here: https://www.dropbox.com/sh/rh1r4vbevpcmq55/AAAlqW7biGD0fMQUhNzXI1B3a?dl=0
I don't use "share" function. Can you test it again @wingsmight ?

Thanks for new dll, but that didn't solve problem with "share" function unfortunately. Callback ShareResult is always Cancelled

@pacolaf
Copy link

pacolaf commented Jun 14, 2021

I built the DLLs for Facebook SDK v11.0 @pacolaf
You can download them here: https://www.dropbox.com/sh/rh1r4vbevpcmq55/AAAlqW7biGD0fMQUhNzXI1B3a?dl=0
I don't use "share" function. Can you test it again @wingsmight ?

Thank you! It solves the login problem. I don't use the "share" function either, so I cannot test it.

@visualbruno
Copy link

Hi @wingsmight
FB.ShareLink works for me.
Did you install first the SDK from Facebook and then overwrite just the DLLs I shared ?

@wingsmight
Copy link

Hi @wingsmight

FB.ShareLink works for me.

Did you install first the SDK from Facebook and then overwrite just the DLLs I shared ?

Hey, yeah, I did exactly what you wrote, but ShareLink returns right value only on Android. On iOS FB always returns cancelled.

@visualbruno
Copy link

@wingsmight Someone created an issue about this bug: #553

@joaquingrech
Copy link

wow, amazing nobody not only tested the sdk at Facebook but also that the fix didn't make it into the last update. You can tell how seriously fb is taking unity XD

@pacolaf
Copy link

pacolaf commented Jul 27, 2021

It seems that the bug is solved, not by Facebook but by Unity. Facebook SDK for Unity v11.0.0 (original) finally working on Unity 2021.1.15f1, at least with my app. Can anybody confirm this?

EDIT: Also working with Facebook SDK v9.0.0.

@snorrsi
Copy link

snorrsi commented Jul 28, 2021

It seems that the bug is solved, not by Facebook but by Unity. Facebook SDK for Unity v11.0.0 (original) finally working on Unity 2021.1.15f1, at least with my app. Can anybody confirm this?

EDIT: Also working with Facebook SDK v9.0.0.

Well spotted @pacolaf .

I haven’t tested this myself but when reading through Unity 2021.1.15 release notes it lists fix for UploadHandlerRaw now accepting null values in Post request.
See https://issuetracker.unity3d.com/issues/uploadhandlerraw-throws-argumentexception-when-a-null-gets-passed-as-the-postdata-parameter-to-the-www-contsructor

I suspect the issue of getting user image from FB.Api was using null in parameter for the UploadHandlerRaw method which makes FB SDK now finally usable with 2021.1.15+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests