question

vrykov avatar image
vrykov asked

Unity SDK il2cpp compilation issue

Hi, I discovered that iOS build does not compile in Release mode in Xcode after building Unity iOS player. The reason is PlayFabEvents.cs file from PlayFab SDK containing 3K lines of C# code in 2 functions, after being compiled by Unity`s il2cpp to C++ file it generates 210K+ lines of code and that C++ file cannot be compiled by Xcode in Release configuration because those 2 functions are too big, on my Mac it never compiles and clang allocates 30+ GB of memory trying to do it.

In Debug mode the game compiles in Xcode and runs on device.

I`ve tried setting Unity iOS player Managed Stripping Level to Medium from current Low - it helped bring the offending .cpp file to 40K lines of code, the game compiles in Release mode but crashes on startup - because the game uses reflection in our scripts some classes get stripped too, need to find them all and manually annotate them not to be stripped. This seems like a painful solution to the problem.

The simplest fix is splitting 2 functions in PlayFabEvents.cs into several smaller ones.

Using PlayFab SDK 2.88.200615

The offending functions are in PlayFabSDK\Shared\Public\PlayFabEvents.cs they are UnregisterInstance and OnProcessingEvent.
I have attached a fixed file which makes it compilable on xcode, it still takes around 4 mins and 6GB of ram, so you can chop them further if you intend to fix this.playfabevents.zip

unity3dsdks
playfabevents.zip (38.0 KiB)
10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

Thanks for your sharing. We will inform our engineering team about it.

10 |1200

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

vrykov avatar image
vrykov answered

Here is SDKGenerator pull request that fixes that: https://github.com/PlayFab/SDKGenerator/pull/728

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.

Sarah Zhang avatar image Sarah Zhang commented ·

Thanks for the feedback.

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.