facebook / facebook-sdk-for-unity

The facebook sdk for unity.
https://developers.facebook.com/docs/unity
Other
489 stars 256 forks source link

MethodAccessException: Attempt to access method 'Facebook.Unity.Canvas.ICanvasFacebookCallbackHandler.OnUrlResponse' on type '' failed. #394

Open hajimeku opened 4 years ago

hajimeku commented 4 years ago

Checklist

Environment

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

Goals

Not have this Exception thrown

Expected Results

Not have this Exception thrown

Actual Results

MethodAccessException: Attempt to access method 'Facebook.Unity.Canvas.ICanvasFacebookCallbackHandler.OnUrlResponse' on type '' failed.

Steps to Reproduce

Cant reproduce it myself, this shows up in the unity crashlytics logs. It happens a lot

ungolyant commented 4 years ago

Hello,

We also had this issue in ~25% of cases of users trying to initialize FB on WebGL in production. What solved it for us is changing from where FB.Init() is called, or more precisely, from which point in Unity update cycle we called it. Exceptions were happening while we have called FB.Init() from a Unity coroutine (i.e. between yield returns), and they stopped happening completely when we moved FB.Init() to be called from a Unity's Update() method. I assume that some edge case was happening, where FB SDK still wasn't finished setting up (creating) GameObjects for handling callbacks from native JavaScript...

Hope this helps, Milos Markovic Nordeus