Swarm IOException - can't build lightmap

I am unable to build the lightmap for a map. I have tried multiple times with the exact same result.

Just after the scene is exported to Swarm, Swarm throws an IOException claiming it can’t access a cache file because it is being used by another process. Except it isn’t, or if it is then it is Swarm’s own processes.

I have tried:
Restarting - straight into Unreal, build lightmap. Same error
Clean & Verify Swarm cache - Swarm says all is good, then it just fails to build with the exact same error
Changing the Swarm cache path - new path, same error. Exact same filename as best I can tell (It is a long hash name)

Error message is below. Please note that I am unable to copy/paste from my production machine to the internet (due to MPAA restrictions) so I had to type the whole thing out. As a result it possibly has a typo or two but should still be accurate.

18:28:49: [Interface:OpenChannel] Error: System.IO.IOException: The process cannot access the file 'D:\UnrealEngine_dev\Engine\Saved\Swarm\SwarmCache\AgentStagingArea\8487AD2E5DBA413C81373D29B2915895.00000000000000000000000000000000.mtrlgz' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.fileStream.ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
at System.IO.FileStrea,ctor(String path, FileMode mode, FileAccess access, FileShare share)
at NSwarm.FSwarmInterface.OpenChannel(String ChannelName, EChannelFlags ChannelFlags)

Hi John -

In the logs it looks as if there is another version of Swarm agent open and accessing the same cache location. Look in your Windows Notification area for a small Gold and Black S icon, if found, close it and attempt to build again.

If that does not work for you and you get a similar error, open up Swarm Agent and Clean and Validate the Cache. Instructions to do this can be found here:

A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

After this if you can let me know if you are still getting the same log message or if it changes.

Thank You

Eric Ketchum

Well I had already tried cleaning the cache and validating it with no luck. I have also done now 3 restarts, so if there is another one running then it itself is spawning it off each and every time. Only one swarm shows up in the taskbar.

EDIT: So I tried another map and it works fine. But go back to the original map and I get the error again.

Hmm… There are two possibilities I can think of here. First Try looking for any null Object actors in your level. These are actors which appear in the World Outliner but actually have no mesh or BP associated with them. Delete any of these you find. They can cause issues with Light Builds.

If that does not work, try deleting your Intermediate, Saved, and Derived Data Cache Folders in your Projects Folder. This will require some Shader and Code recompiling but, often will clear up an corrupted data that has been incorrect stored there. Since you are able to build another map I am thinking something has gotten corrupted in the problem level and often clearing these directories and allowing a rebuild can solve the issue.

Let me know again if the Log Changes-

Eric Ketchum

Thanks Eric. I started removing objects one by one and found the culprit. Nothing seems visually wrong with the mesh but a “Map Check” throws a warning saying it has “7 elements with 0 triangles”, and if I remove that StaticMesh then everything works fine.

Might be nice if Swarm/Lightmass was a bit more upfront with what the problem is, but I guess this solves it for me. Or at least points me to what I need to look at.

[Interface:OpenChannel] Error: System.IO.IOException: The process cannot access the file ‘C:\Users\Expressive\AppData\Local\UnrealEngine\5.3\Saved\Swarm\SwarmCache\AgentStagingArea\v2.78377A59B5528BC04AB2E9118FF8B19EE0A6F484.F1D9D1273D5C02B018C5337E52EE45E707771904.mtrlgz’ because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share)
at NSwarm.FSwarmInterface.OpenChannel(String ChannelName, EChannelFlags ChannelFlags) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Editor\SwarmInterface\DotNET\SwarmInterface.cs:line 1604

this is my swarm agents error message, I’m using ue 5.3. actually its a ancient city with 50 unique building and others element. and i think the problem started when i upgrade the project from ue4.26 to 5.1. still i cannot solve it. can someone help?

You have to delete the contents of Swarm directory as you have a corrupted file