question

drallcom3 avatar image
drallcom3 asked

libCurl bug in Unity 2021.1.3f1

Unity updated the libCurl in version 2021.1.3f1. This results in a

Curl error 61: Unrecognized content encoding type. libcurl understands identity content encodings.

error for any use of the Playfab API. Updating the Playfab SDK did not solve the issue.

When using 2021.1.2, which does not have the libCurl update, I have no issues.

apis
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.

Akash avatar image Akash commented ·

Oh so this is not the case on 2021.1.2?

Thank you so much for this, my dev stalled the whole day today.

0 Likes 0 ·
drallcom3 avatar image drallcom3 Akash commented ·

2021.1.2 is fine. The patch notes for 2021.1.3 even mention libCurl, so that's probably it.

1 Like 1 ·
Rick Chen avatar image
Rick Chen answered

The issue seems to be that from Unity 2021.1.3f1, UnityWebRequest no longer supports data compression. The error "Curl error 61: Unrecognized content encoding type. libcurl understands identity content encodings." states that it only accepts the identity content encodings, other encoding such as "gzip" may not work, this does not only apply to PlayFab's SDK, but also other websites that uses data compression. Please ask the Unity team for help and see if this is intended or a bug from Unity side.

Here are some solutions:

1. You could use the LTS version of Unity 2020.

2. If you do not wish to compress the data, you could uncheck the Compress Api Data in the PlayFab Shared Settings.

3. You could also choose other Request Type than "Unity Web Request" in the PlayFab Shared Settings.

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.

drallcom3 avatar image drallcom3 commented ·

Update: libCurl (and therefore UnityWebRequest) does not support compression anymore in Windows. This includes the editor, even with Android set as a platform! Builds for mobile devices etc are fine. The Playfab SDK does not consider this and UnityWebRequest throws an error.

Therefore all you have to do to fix this is change

#if !UNITY_WSA && !UNITY_WP8 && !UNITY_WEBGL

in PlayFabUnityHttp.cs to

#if !UNITY_WSA && !UNITY_WP8 && !UNITY_WEBGL && !UNITY_EDITOR

and that's it. Probably extend it to everything Windows (users say Windows builds have the problem too). No idea about editors on other platforms.

If someone is targetting Windows and really really needs API compression, they have to stick to 2020 LTS. For now. At some point Unity will add compression for Windows.

Case solved (I hope).

1 Like 1 ·
Justin Heasman avatar image Justin Heasman drallcom3 commented ·

You would need to include "!UNITY_STANDALONE_WIN" too because the issue happens with Windows Builds as well as the Editor.

0 Likes 0 ·
drallcom3 avatar image drallcom3 commented ·

I've asked Unity and made a bug report to them. Answer: "Not a bug, third party SDKs (you) have to deal with it somehow."

Also Unity: "But the current issue is indeed third party relying on being able to set a particular HTTP header we explicitly advise against in our documentation (and were forbidding entirely in the past)."

In PlayFabUnityHttp.cs you set accept-encoding to a certain value. The documentation strongly recommends not to do this (as it's unreliable). Simply removing the offending header causes the server to send uncompressed data (no surprise there).

Sure we can use Playfab without compression, but I fear that might get very expensive very quickly.

0 Likes 0 ·
playfab-11 avatar image
playfab-11 answered

Upgrade to 2021.1.3, and since then I also have the libCurl error... Was fine in 2021.1.2 just before.

Any solution?

10 |1200

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

Justin Heasman avatar image
Justin Heasman answered

Same issue here. Just rolled back to 2021.1.2 and PlayFab works perfectly again.

10 |1200

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

Basile Perrenoud avatar image
Basile Perrenoud answered

Seems to be a problem with the gzip encoding.

If you don't want to downgrade Unity but are ok with uncompressed data, you can try unchecking "Compress API data" in your PlayFabSharedSettings file

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.

Akash avatar image Akash commented ·

So many thanks for this, never would have I figured this out. Really, a ton of thanks to you :D

0 Likes 0 ·
Gerardo Melendrez avatar image
Gerardo Melendrez answered

Same issue here.

10 |1200

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

Justin Heasman avatar image
Justin Heasman answered

Any news on getting this bug fixed?

10 |1200

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

drallcom3 avatar image
drallcom3 answered

It works if I force "X-Accept-Encoding" to "identity". "Content-Encoding" is still "gzip". So do what the error message literally wants.

Is the request still compressed? I don't know. Maybe? Wouldn't Gzip complain otherwise?

10 |1200

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

astrakh avatar image
astrakh answered

> It works if I force "X-Accept-Encoding" to "identity"

How did you do that?

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.

drallcom3 avatar image drallcom3 commented ·

In PlayFabUnityHttp.cs do

reqContainer.RequestHeaders["X-Accept-Encoding"] = "identity"
0 Likes 0 ·
astrakh avatar image
astrakh answered

This error was there for a long time as a warning and Playfab team seems to ignored it completely for quite some time. Now Unity team decided to make it an error and I hope Playfab team will address it at nearest future for us to be able to upgrade.

10 |1200

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

astrakh avatar image
astrakh answered

I have switched from custom request to Unity Web Request and disabled compress API data and it works now. I also got the latest SDK (which wasn't enough to fix the issue:

https://docs.microsoft.com/en-us/gaming/playfab/sdks/unity3d/


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.

Kenny Roy avatar image Kenny Roy commented ·

Can we get a response from PF as to what the performance cost is from not compressing API data?

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.