Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-773

[Bug]: Unity3D - Weaver Always Runs, regardless of Assembly Structure

      What happened?

      We have our Data Models in a separate Assembly, that's where all our RealmObject inheritors live.
      Our Main Scripts Assembly references that assembly, so it only gets recompiled if the actual Models change.

      However, unexpectedly, there is a 1 second Weaver operation on every compile, regardless of whether it involved the AoE.DataModels assembly. This seems to make up a considerable chunk of our iteration times.

      If weaving manually via the Tools Menu, the tax is lower:

      Expected behaviour:
      Weaver is either 0ms on a no-change compile; or skipped entirely, if the assembly that contains the RealmObjects does not get recompiled itself.

      Repro steps

      1. Put your RealmObject inheritors into a separate Assembly (let's call it RealmObjects Assembly).
      2. Reference that Assembly in your Scripts Assembly (may need to create one from scratch)
      3. Compile everything, clear console.
      4. Change a File in the Scripts Assembly, which will trigger a Recompile
      5. Observe: Weaver runs, even though the RealmObjects Assembly does not change, does not get recompiled, and thus doesn't need its classes to be woven.

      Version

      10.12.0

      What SDK flavour are you using?

      MongoDB Realm (i.e. Sync, auth, functions)

      What type of application is this?

      Unity

      Client OS and version

      Win11, Unity 2022.1.0f1 but reproduced also on 2021.3.x LTS and before

      Code snippets

      No response

      Stacktrace of the exception/crash you're getting

      No response

      Relevant log output

      ```shell

      Triggered by Recompile (even though AoE.WorldMap is not being compiled as it hasn't changed)

      [AoE.WorldMap] Weaving completed in 981 ms.
      0 classes were woven:

      UnityEngine.Debug:Log (object)
      RealmWeaver.UnityWeaver/UnityLogger:Info (string)
      RealmWeaver.UnityWeaver:WeaveAssemblyCore (string,System.Collections.Generic.IEnumerable`1<string>,string,string)
      RealmWeaver.UnityWeaver/<>c:<Initialize>b__14_1 (string,UnityEditor.Compilation.CompilerMessage[])
      UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[])


      Manual Weave

      Weaving completed. 0 assemblies needed weaving.
      UnityEngine.Debug:Log (object)
      RealmWeaver.UnityWeaver/UnityLogger:Info (string)
      RealmWeaver.UnityWeaver/<WeaveAllAssembliesMenuItem>d__15:MoveNext ()
      System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<int>:SetResult (int)
      RealmWeaver.UnityWeaver/<WeaveAllAssemblies>d__19:MoveNext ()
      UnityEngine.UnitySynchronizationContext:ExecuteTasks ()
      ```

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: