question

studio avatar image
studio asked

Unity Login Eror

Hey ,

I have been getting an error on my device now , but I am not sure how to fix it. It only happens on my devices but works fine in the editor

AndroidPlayer(Google_Pixel_XL@192.168.0.3)</i> Unhandled error in PlayFabWWW: System.NullReferenceException: Object reference not set to an instance of an object at UnityEngine.WWW.get_responseHeaders () [0x00076] in /Users/builduser/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:158 at PlayFab.Internal.PlayFabWww+<Post>c__Iterator0.MoveNext () [0x0007c] in /Volumes/GAME DEV MAN/kamidrop/Assets/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabWWW.cs:153 (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

Any one got any ideas ?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image 1807605288 ♦ commented ·

Can you please verify which version of Unity you are using?

0 Likes 0 ·
1807605288 avatar image
1807605288 answered

[UPDATE]

For clarification, a permanent fix was submitted to the PlayFab SDK, and so you should not modify PlayFab files.

https://api.playfab.com/releaseNotes/#171016

Simply update to the latest PlayFab SDK via Editor Extensions, or this UnityPackage.

[Original Post]

We have figured out the issue now.

The recent Unity patch seems to have broken something inside of the Unity WWW class. The failure os on a line where we are trying to fetch the response headers from the result.

Formerly, if there were no headers, Unity would return an empty dictionary, and we'd proceed as normal. Now, Unity is instead just throwing an exception. We've got a small update that can fix this error, but ultimately it's a bug in Unity.

We'll release this fix officially as soon as we can, but until then, here's the fix you can copy/paste manually.

replace lines 161 & 162:

string encoding;
if (www.responseHeaders.TryGetValue("Content-Encoding", out encoding) && encoding.ToLower() == "gzip")

With this:

string encoding;
Dictionary<string, string> responseHeaders = null;
try {
	responseHeaders = www.responseHeaders;
} catch (Exception) { }
if (responseHeaders != null && responseHeaders.TryGetValue("Content-Encoding", out encoding) && encoding.ToLower() == "gzip")

And this will get you working again. Sorry for the inconvenience.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image 1807605288 ♦ commented ·

For clarification, a permanent fix was submitted to the PlayFab SDK, and so you should not modify PlayFab files.
https://api.playfab.com/releaseNotes/#171016
Simply update to the latest PlayFab SDK via Editor Extensions, or this UnityPackage.

1 Like 1 ·
emmanuelcap avatar image emmanuelcap 1807605288 ♦ commented ·

Great! Thanks for the feeback.

0 Likes 0 ·
emmanuelcap avatar image emmanuelcap commented ·

Sorry for the bump, but I am having the same problem and I don't get which file should I edit.

0 Likes 0 ·
1807605288 avatar image
1807605288 answered

I'm looking at PlayFabWWW.cs, line 153

My first guess is you can try to replace this:

if (www.responseHeaders.TryGetValue("Content-Encoding", out encoding) && encoding.ToLowerInvariant() == "gzip")

with this:

if (www.responseHeaders != null && www.responseHeaders.TryGetValue("Content-Encoding", out encoding) && !string.IsNullOrEmpty(encoding) && encoding.ToLowerInvariant() == "gzip")

That should handle every possible circumstance, but this line is VERY thoroughly tested on lots of environments and platforms, so I suspect your environment is different in some way we've not seen before. None the less, give that a try and let us know.

Thanks

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1807605288 avatar image 1807605288 ♦ commented ·

This did not work. This is an exception inside of the Unity Code, not ours.

Can you please verify which version of Unity you are using?

1 Like 1 ·
studio avatar image studio 1807605288 ♦ commented ·

I am using unity 2017.1.1p3, I got the code to work but I have to comment out all the code that referenced www.responseHeader

1 Like 1 ·
bonozogames avatar image bonozogames commented ·

@Paul Gilmore @studio I, too, just started getting this show-stopper error, only on Android not editor nor iOS, after upgrading from Unity 2017.1.1f1 to Unity2017.1.1p3 !

1 Like 1 ·
robert avatar image
robert answered

Same here. No changes to our login related code, used to work fine, exact same error as posted above. Using Unity 2017.1.1p3. No problems with iOS or Unity Editor.

The crash happens inside the getter of responseHeaders, so checking for null is also not possible. We can only comment the entire code dealing with responseHeaders for now.

unity related issue: https://issuetracker.unity3d.com/issues/www-dot-responseheaders-object-is-null-if-there-is-no-internet-connection?_ga=2.230443226.750563462.1506933764-215048564.1465622404

For us this happens also with a working internet connection. We removed the entire responseHeader check branch now as a temporary "fix" hoping that playfab doesn't returned gzipped data.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

robert avatar image robert commented ·

This are the recent WWW related changes in Unity 2017.1.1p3:

  • (936801) - UnityWebRequest : Fixed a possible freeze on iOS, when running multiple UnityWebRequests with custom download handler scripts.
  • (none) - UnityWebRequest : Fixed early availability of status code when UnityWebRequest was still running.
  • (none) - UnityWebRequest : Ensure that headers are available in UnityWebRequest only after all of them are received.
  • (none) - UnityWebRequest : Fixed possible issues aborting UnityWebRequest when using a custom download handler script.
0 Likes 0 ·
studio avatar image studio commented ·

The same here, IOS build works fine just android, that unity issue say that it is due to loss of network, does that mean that unity is losing internet. If we check keep connection alive will that fix the issue , going to test now

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.