Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No properties in xxxRealmObject #3631

Closed
jykgod opened this issue Jun 19, 2024 · 6 comments
Closed

No properties in xxxRealmObject #3631

jykgod opened this issue Jun 19, 2024 · 6 comments
Labels
App-type:Unity More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community SDK-Use:Local T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed

Comments

@jykgod
Copy link

jykgod commented Jun 19, 2024

What happened?

Build Task WriteFileList failed with exception:
No properties in AssetPackageRealmObject, has linker stripped it? See https://docs.mongodb.com/realm/sdk/dotnet/troubleshooting/#resolve-a--no-properties-in-class--exception
  at Realms.Schema.ObjectSchema+Builder..ctor (System.Type type) [0x00140] in <868b6b354c524faeb87463960e954113>:0 
  at Realms.Schema.ObjectSchema+<>c.<FromType>b__24_0 (System.Type t) [0x00000] in <868b6b354c524faeb87463960e954113>:0 
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <80e08c2cc04049bf931fc9038d04f397>:0 
  at Realms.Schema.ObjectSchema.FromType (System.Type type) [0x0000b] in <868b6b354c524faeb87463960e954113>:0 
  at Realms.Schema.RealmSchema+Builder.Add (System.Type type) [0x0000b] in <868b6b354c524faeb87463960e954113>:0 
  at Realms.Schema.RealmSchema+Builder..ctor (System.Collections.Generic.IEnumerable`1[T] types) [0x00021] in <868b6b354c524faeb87463960e954113>:0 
  at Realms.Schema.RealmSchema.op_Implicit (System.Type[] objects) [0x00003] in <868b6b354c524faeb87463960e954113>:0 
  at Orcas.Asset.AssetManager.GetFileListFormFilePath (System.String filePath, System.Boolean isReadOnly) [0x00019] in E:\Projects\Merge2\Packages\[email protected]\Runtime\Core\AssetManager.cs:210 
  at Orcas.Asset.WriteFileList.Run () [0x00267] in E:\Projects\Merge2\Packages\[email protected]\Editor\BuildTask\WriteFileList.cs:96 
  at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList`1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x000cd] in E:\Projects\Merge2\Library\PackageCache\[email protected]\Editor\Shared\BuildTasksRunner.cs:56 

I get the exception while my project building in the batch mode.
The WriteFileList is a build task in my SBP like this:

internal class WriteFileList : IBuildTask
    {
        public int Version { get; }
        
#pragma warning disable 649
        [InjectContext(ContextUsage.In)]
        IBundleBuildParameters m_Parameters;
        
        [InjectContext]
        IBuildInfoContext m_BuildInfoContext;
        
        [InjectContext]
        IDependencyData m_DependencyData;

        [InjectContext]
        IBundleBuildResults m_Results;
#pragma warning restore 649
        
        public ReturnCode Run()
        {
            if (m_BuildInfoContext.Variant != null) return ReturnCode.Success;
            
            var realmFilePath = m_Parameters.GetOutputFilePathForIdentifier("FileList.realm");
            if (File.Exists(realmFilePath))
            {
                File.Delete(realmFilePath);
            }
            
            var realm = AssetManager.GetFileListFormFilePath(realmFilePath);
            ...
     }

And the GetFileListFormFilePath in AssetManager.cs is:

public static Realm GetFileListFormFilePath(string filePath, bool isReadOnly = false)
        {
            if (isReadOnly && File.Exists(filePath) == false)
            {
                return null;
            }
            var configuration = new RealmConfiguration(filePath)
            {
                Schema = new[]
                {
                    typeof(AssetPackageRealmObject), typeof(AssetBundleRealmObject), typeof(AssetRealmObject),
                    typeof(DownLoadedABRealmObject), typeof(BuildConfigRealmObject)
                },
                IsReadOnly = isReadOnly
            };
            return Realm.GetInstance(configuration);
        }

This exception only occurs in the batch mode!
I firstly guess these realm object classes may not woven correctly. But in the build log I find them look like correct.
The part of Build Log:

[Orcas.Asset.Manager] Weaving completed in 68 ms.
5 classes were woven:
<b>AssetBundleRealmObject</b>
      <i>Name</i>: String [PrimaryKey]
      <i>FileName</i>: String
      <i>Hash</i>: String
      <i>CRC</i>: String
      <i>Size</i>: Int64
      <i>Dependencies</i>: IList`1<Orcas.Asset.AssetBundleRealmObject>

<b>AssetPackageRealmObject</b>
      <i>Name</i>: String [PrimaryKey]
      <i>Internal</i>: Boolean
      <i>IsDependence</i>: Boolean
      <i>Version</i>: Int64
      <i>ApplyVariantExt</i>: String
      <i>VariantsExt</i>: IList`1<System.String>
      <i>AssetBundles</i>: IList`1<Orcas.Asset.AssetBundleRealmObject>

<b>AssetRealmObject</b>
      <i>Path</i>: String [PrimaryKey]
      <i>AssetBundle</i>: AssetBundleRealmObject

<b>BuildConfigRealmObject</b>
      <i>Id</i>: Int32 [PrimaryKey]
      <i>BigQueryVersion</i>: String
      <i>Environment</i>: Int32

<b>DownLoadedABRealmObject</b>
      <i>FileName</i>: String [PrimaryKey]

UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
RealmWeaver.UnityWeaver/UnityLogger:Info (string)
RealmWeaver.UnityWeaver:WeaveAssemblyCore (string,System.Collections.Generic.IEnumerable`1<string>,RealmWeaver.Analytics/Config)
RealmWeaver.UnityWeaver/<>c:<Initialize>b__18_1 (string,UnityEditor.Compilation.CompilerMessage[])
UnityEditor.Compilation.CompilationPipeline/<>c:<SubscribeToEvents>b__23_2 (UnityEditor.Scripting.ScriptCompilation.ScriptAssembly,UnityEditor.Compilation.CompilerMessage[])
UnityEditor.Scripting.ScriptCompilation.EditorCompilation:InvokeAssemblyCompilationFinished (UnityEditor.Scripting.ScriptCompilation.ScriptAssembly[],Bee.BeeDriver.BeeDriverResult,UnityEditor.Scripting.Compilers.CompilerMessage[][])
UnityEditor.Scripting.ScriptCompilation.EditorCompilation:ProcessCompilationResult (UnityEditor.Scripting.ScriptCompilation.ScriptAssembly[],Bee.BeeDriver.BeeDriverResult,object)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[])
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[])
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScriptsNative (UnityEditor.Build.Player.ScriptCompilationSettings,string,bool)
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScriptsInternal (UnityEditor.Build.Player.ScriptCompilationSettings,string,bool)
UnityEditor.Build.Player.PlayerBuildInterface:CompilePlayerScripts (UnityEditor.Build.Player.ScriptCompilationSettings,string)
UnityEditor.Build.Pipeline.Tasks.BuildPlayerScripts:Run () (at Library/PackageCache/[email protected]/Editor/Tasks/BuildPlayerScripts.cs:41)
UnityEditor.Build.Pipeline.BuildTasksRunner:Run (System.Collections.Generic.IList`1<UnityEditor.Build.Pipeline.Interfaces.IBuildTask>,UnityEditor.Build.Pipeline.Interfaces.IBuildContext) (at Library/PackageCache/[email protected]/Editor/Shared/BuildTasksRunner.cs:56)
UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles (UnityEditor.Build.Pipeline.Interfaces.IBundleBuildParameters,UnityEditor.Build.Pipeline.Interfaces.IBundleBuildContent,UnityEditor.Build.Pipeline.Interfaces.IBundleBuildResults&,System.Collections.Generic.IList`1<UnityEditor.Build.Pipeline.Interfaces.IBuildTask>,UnityEditor.Build.Pipeline.Interfaces.IContextObject[]) (at Library/PackageCache/[email protected]/Editor/ContentPipeline.cs:145)
Orcas.Asset.BuildPackageHelper:BuildAssetBundles_Internal 
...

The full build log file:
buildtest.log

Repro steps

1.Build Project.
2.Got the exception of "no properties in...".

Version

Unity .Net Framework

What Atlas Services are you using?

Local Database only

What type of application is this?

Unity

Client OS and version

Unity2021.3.38f1 & Realm-dotnet 12.0.0

Code snippets

No response

Stacktrace of the exception/crash you're getting

Relevant log output

No response

Copy link

sync-by-unito bot commented Jun 19, 2024

➤ PM Bot commented:

Jira ticket: RNET-1160

@nirinchev
Copy link
Member

How does AssetBundleRealmObject look like? Also, do you think you can share the built .dll that contains the models? I'd be curious to see what the compiled library looks like.

@jykgod
Copy link
Author

jykgod commented Jun 19, 2024

How does AssetBundleRealmObject look like? Also, do you think you can share the built .dll that contains the models? I'd be curious to see what the compiled library looks like.

using System.Collections.Generic;
using Realms;

namespace Orcas.Asset
{
    [Preserve(AllMembers = true)]
    public class AssetBundleRealmObject : RealmObject
    {
        [PrimaryKey]
        public string Name { get; set; }
        public string FileName { get; set; }
        public string Hash { get; set; }
        public string CRC { get; set; }
        public long Size { get; set; }
        public IList<AssetBundleRealmObject> Dependencies { get; }
    }
}

I'm not sure what the status of the DLL file is during the build process because we first compile it using HybridCLR before proceeding with the build process. I noticed in the packaging log that weaving was automatically executed during the execution of the BuildPlayerScripts script, and theoretically it should be correct by the time WriteFileList is executed. However, my current guess is that maybe the DLL loaded into memory is still from before weaving, which causes an error.

@jykgod
Copy link
Author

jykgod commented Jun 19, 2024

How does AssetBundleRealmObject look like? Also, do you think you can share the built .dll that contains the models? I'd be curious to see what the compiled library looks like.

DLL:
Orcas.Asset.Manager.zip

@jykgod
Copy link
Author

jykgod commented Jun 19, 2024

@nirinchev
I just tried separating the HybridCLR's compilation and project's packaging into two Unity cmd commands, with a woven cmd commands in between, and it compiled successfully! Thank you!

public static void Woven()
    {
        RealmWeaver.UnityWeaver.Initialize();
        RealmWeaver.UnityWeaver.WeaveAllAssembliesMenuItem();
        Thread.Sleep(20000);
    }

@sync-by-unito sync-by-unito bot added More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Jul 22, 2024
Copy link
Contributor

github-actions bot commented Aug 6, 2024

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@github-actions github-actions bot closed this as completed Aug 6, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
App-type:Unity More-information-needed More information is needed to progress. The issue will close automatically in 2 weeks. O-Community SDK-Use:Local T-Bug Waiting-For-Reporter Waiting for more information from the reporter before we can proceed
Projects
None yet
Development

No branches or pull requests

2 participants