Addressables build stuck on "Write Serialized Files" for hours, uses all RAM+pagefile then crashes

Hi,

I’m no longer able to build addressables for our game, meaning I can’t build the game.

As the title indicates, the process gets stuck on “Write Serialized Files”, uses all the available RAM and virtual memory from the pagefile, and crashes Unity after hours of being stuck.

9856692--1419558--Unity_WNykQ8jqw0.png

Setup:

  • Unity 2020.3.48f1 LTS
  • Addressables package version 1.21.19 (avoiding 1.21.21 due to a reported major performance regression)
  • High-end development PC (16GB RAM, SSD, Intel 13th Gen Core i7-13700, etc.)

What I’ve tried:

  • Splitting our addressables into smaller bundles

  • Running “Check Duplicate Bundle Dependencies” and clean any duplicate entry

  • Disabling CRC on all bundles

  • Rebuilding the entire project Library/

  • Increasing the pagefile to 64GB

  • Restarting my PC

Related issues I’ve found, but I don’t think they’re the fix:

Questions:

  • Is there any way I can know which bundle is being serialized with this dialog path in the screenshotted progress bar? It’s always the same ID which I assume is a hash (CAB-385dd2…), but I can’t seem to find the hash associated to a bundle in the GUI. I looked in Library/BuildCache, but that ID can’t be found, presumably before Unity crashes before it could serialize it.

  • Say I have to test each bundle, is there even a way to do that? Can I build a single bundle at a time and see what’s crashing? How? If not, should I just start deleting bundles in a binary-search way to build until it starts working again?

Please help! This is an urgent issue for us, as it’s preventing our final build from entering QA on time. Any help would be greatly, greatly appreciated. I’m at the end of my wits here. Please share any insight you may have to debug this!

I figured out the cause: we had too many shader variants (probably went up exponentially because of one or two new pragma multi_compile since the last successful build). I was able to trim down the number of variants by using shader_feature when possible.

I imagine Addressables should probably error out more nicely in this case and I should probably file a report, but unfortunately I’m too rushed at the moment to do so.

Someone also pointed out it may be related to this memory issue , which in turn references five other memory leak reports describing a similar problem. If an Addressables dev finds this thread, please consider improving the error reporting / failure handling in cases where a bundle is too big to be supported. It’s fine to ask the user to shrink/split it somehow, but we need some help figuring out what to target, otherwise we’re left in the dark with a memory leak crashing the system.