How to disable/limit Fusion Unity SDK from weaving all DLLs?

Options

Whenever Unity triggers a code recompile, frequently Fusion.CodeGen reweaves all the DLLs in the project regardless of whether they have any Fusion related code in them or not. Is there a way to limit which DLLs, AsmDefs, or (best) specific files get weaved?


Here are some of the logs from Unity Editor.log:


- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.SysrootPackage.Editor.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.SysrootPackage.Editor.dll in 0.106074 seconds

- Finished ILPostProcessorRunner in 0.591806 seconds

- Finished compile Library/ScriptAssemblies/Unity.SysrootPackage.Editor.dll in 257.185127 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.RenderPipelines.Universal.Editor.Tests.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.RenderPipelines.Universal.Editor.Tests.dll in 0.099881 seconds

- Finished ILPostProcessorRunner in 0.55889 seconds

- Finished compile Library/ScriptAssemblies/Unity.RenderPipelines.Universal.Editor.Tests.dll in 260.660523 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Addressables.Editor.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Addressables.Editor.dll in 0.0993 seconds

- Finished ILPostProcessorRunner in 0.583428 seconds

- Finished compile Library/ScriptAssemblies/Unity.Addressables.Editor.dll in 264.505775 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Tilia.Visuals.CollisionFader.Unity.Runtime.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Tilia.Visuals.CollisionFader.Unity.Runtime.dll in 0.09446 seconds

- Finished ILPostProcessorRunner in 0.561937 seconds

- Finished compile Library/ScriptAssemblies/Tilia.Visuals.CollisionFader.Unity.Runtime.dll in 252.523622 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Sysroot.Linux_x86_64.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Sysroot.Linux_x86_64.dll in 0.096249 seconds

- Finished ILPostProcessorRunner in 0.524489 seconds

- Finished compile Library/ScriptAssemblies/Unity.Sysroot.Linux_x86_64.dll in 256.437739 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Fusion.Addressables.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Fusion.Addressables.dll in 0.087463 seconds

- Finished ILPostProcessorRunner in 0.4951 seconds

- Finished compile Library/ScriptAssemblies/Fusion.Addressables.dll in 228.186748 seconds

- Starting ILPostProcessorRunner

- Starting ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Toolchain.Win-x86_64-Linux-x86_64.dll

- Finished ILPostProcessor 'Fusion.CodeGen.ILWeaverBindings' on Unity.Toolchain.Win-x86_64-Linux-x86_64.dll in 0.086952 seconds

- Finished ILPostProcessorRunner in 0.478356 seconds

- Finished compile Library/ScriptAssemblies/Unity.Toolchain.Win-x86_64-Linux-x86_64.dll in 231.574042 seconds

- Finished script compilation in 486.077341 seconds

Answers

  • ramonmelo
    Options

    Hi @justdizzy ,


    Yes, it should be straightforward to limit which DLLs are Weaved.

    Open the NetworkProjectConfig asset and look for the "Assemblies To Weave" section, select the ones you don't want to Weave and remove them from the list, save and see how it goes.


    --

    Ramon Melo

    Photon Fusion Team

  • justdizzy
    Options

    I have this set to only Assembly-CSharp and Assembly-CSharp-firstpass, but the issue persists.

  • ramonmelo
    Options

    Hi @justdizzy ,


    Which SDK version are you using? Does this also happen on the latest version?


    --

    Ramon Melo

    Photon Fusion Team

  • justdizzy
    Options

    It happens in both 1.0.0 Stable and 1.1.0 Nightly.

  • pgwiazdowski
    edited April 2022
    Options

    What you are observing is as expected, except for those ridiculous compile times. Weaving is actually a two-pass process, first being checking whether a DLL should be altered or not. That's why you see ILPostProcessor in the log.

    Does disabling the weaver reduce compile times?

    Also, what Unity version are you on?

  • justdizzy
    Options

    Unity 2020.3.23

    How do I disable weaving? If I do, will my networking classes not work?

  • pgwiazdowski
    Options

    To make absolutely sure ILPostProcessor is not used, simply remove Assets/Photon/FusionCodeGen folder.

  • gfaraj
    Options

    I'm having an issue with an assembly I'm using from an external package. I keep getting the error

    Session join/create failed. Type Foo.Components.FoobarGameRoomController has not been weaved. Has the assembly Foo been added to NetworkProjectConfig?

    I tried adding the Foo assembly to Assemblies to Weave but it just gets automatically removed the next time I run the game in the editor. And the same error shows up.

    If I remove the FusionCodeGen folder I get this:

    Session join/create failed. Type ControllerPrototype has not been weaved. Has the assembly Assembly-CSharp been added to NetworkProjectConfig?

    Any help would be appreciated.

  • gfaraj
    Options

    @ramonmelo @photon I have not gotten a response here nor in the discord about the above. Is having common networked components in a separate UPM package not supported?