Skip to main content

Impact On the App Size

After integrating HybridCLR, there is a slight increase in package size, mainly due to the following components:

  1. The core code of HybridCLR, excluding MethodBridge.cpp.
  2. The bridge function file MethodBridge.cpp.
  3. The cpp code generated by il2cpp from the HybridCLR.Runtime.dll code.

Among these, the code in part 1 is less than 30,000 lines, and the code in part 3 is less than 2,000 lines, which have minimal impact on the final package size. The size of MethodBridge.cpp is calculated based on the AOT assemblies. Generally, the larger the AOT assemblies, the larger the MethodBridge.cpp file. Typically, depending on the complexity of the project’s AOT modules, the size of MethodBridge.cpp ranges from 2MB to 40MB.

We conducted a test project to measure the actual impact of HybridCLR on package size.

Testing

We tested the package size of an Android Armv8 platform APK built with Unity 2021.

The AOT portion of the test project fully includes the following frameworks and libraries:

We calculated the total size of the AOT module DLLs in the built APK: 12.0MB.

The hot-update portion of the test project includes the following:

  • Unit test project code.
  • Configuration code generated by Luban.

The compiled HotUpdate.dll is 1216KB. To ensure fairness, the hot-update DLLs in projects integrated with HybridCLR are compressed and included in the StreamingAssets package.

We compared the package size across the following eight scenarios:

  • NotHybridCLR-NotHotUpdateCode: Without HybridCLR integration and without including HotUpdate code (HotUpdate is not part of AOT).
  • HybridCLR-NotHotUpdateCode-NotMethodBridge: Integrated with HybridCLR, without HotUpdate code, and with an empty bridge function file.
  • HybridCLR-NotHotUpdateCode-MethodBridge: Integrated with HybridCLR, without HotUpdate code, and with a normal bridge function file.
  • NotHybridCLR-HotUpdateCode: Without HybridCLR integration and with HotUpdate code included (HotUpdate is part of AOT).
  • HybridCLR-HotUpdateCode-NotMethodBridge: Integrated with HybridCLR, with HotUpdate code included (compressed HotUpdate.dll in the StreamingAssets package), and with an empty bridge function file.
  • HybridCLR-HotUpdateCode-MethodBridge: Integrated with HybridCLR, with HotUpdate code included, and with a normal bridge function file.
  • HybridCLR Ultimate Edition-NotHotUpdateCode-MethodBridge Integrated with HybridCLR Ultimate Edition, without HotUpdate code, and with a normal bridge function file.
  • HybridCLR Ultimate Edition-HotUpdateCode-MethodBridge Integrated with HybridCLR Ultimate Edition, with HotUpdate code included, and with a normal bridge function file.

The test data is as follows:

Build TypeAPK Size (KB)global-metadata.dat (Uncompressed)global-metadata.dat (Compressed)libil2cpp.so (Uncompressed)libil2cpp.so (Compressed)HotUpdate.dll Size (Uncompressed, KB)MethodBridge.cpp Size (KB)
NotHybridCLR-NotHotUpdateCode30066100877402980934733836801895478600
HybridCLR-NotHotUpdateCode-NotMethodBridge30262100753602904652740264881915876900
HybridCLR-NotHotUpdateCode-MethodBridge309001007536029046527845016819905020015082
NotHybridCLR-HotUpdateCode31718108930563103289796702082038701812060
HybridCLR-HotUpdateCode-NotMethodBridge30531100812322906522741589281917716512060
HybridCLR-HotUpdateCode-MethodBridge3125910081232290652278492496199205061206

|HybridCLR_UltimateEdition-NotUserCode-MethodBridge|31022|10078796|2905605|78643792|19935716|0|14837| |HybridCLR_UltimateEdition-UserCode-MethodBridge|32910|10893080|3103310|85964616|21622297|1206|15179|14861 |

Uncompressed indicates the original size of the file within the APK, and Compressed indicates the compressed size within the APK.

The original size of the hot-update code HotUpdate.dll is 1216KB, which is compressed to 200KB.

Based on the above test project, we can draw the following conclusions:

  • The core part of HybridCLR, excluding MethodBridge.cpp, increases the package size by 196KB.
  • The bridge function file increases the package size by approximately {MethodBridge.cpp Size} * 0.049.
  • For every additional size S of game code, an app without HybridCLR integration increases in size by S * 1.37.
  • For every additional size S of game code, an app with HybridCLR integration increases in size by S * 0.2.
  • For every additional size S of game code, the Ultimate Edition increases the package size by S * 1.56.
  • When no update assemblies are included, the Ultimate Edition increases the package size by 32KB compared to the Community version.

Summary

Community, Professional, and Hot Reload Edition

Integrating HybridCLR increases the package size by 196k + {MethodBridge.cpp File Size} * 0.049, but moving game code from AOT to hot updates can reduce the package size by {HotUpdate.dll Size} * 1.17.

This means that if the hot-update code in a project exceeds 800KB-1500KB, integrating HybridCLR will result in a smaller final package size compared to not integrating it. The total package size reduction can be approximately calculated as HotUpdate.dll Size * 1.05.

Ultimate Editionn

Integrating HybridCLR increases the package size by 228k + {MethodBridge.cpp File Size} * 0.049.
Newly added code in the DHE assemblies will increase the package size by {New DHE Assembly Size} * 1.56.
Moving game code from AOT to the DHE assemblies will increase the package size by {New DHE Assembly Size} * 0.19.