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

Missing script and Serialization layout errors in built products [USDU-487] #412

Open
joshbaran opened this issue Sep 12, 2023 · 3 comments

Comments

@joshbaran
Copy link

When running a built product, there are many warnings and errors in the log while loading. This has been reported before, but those issues are 3 years old, so I thought I'd start a new one instead of reopening those.

This happens on a project that uses Import as GameObjects. I have not tried the other import options. Everything works without errors in the Unity Editor, but if you run a product of a build, It looks like it reports this warning and error for every imported GameObject:
`[Warning] The referenced script on this Behaviour (Game Object 'Cylinder_005') is missing! (build.framework.js.gz, line 10)

[Error] A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 32 bytes but expected 64 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

_JS_Log_Dump (build.framework.js.gz:10:36497)
wasm-stub
<?>.wasm-function[903]
<?>.wasm-function[23245]
<?>.wasm-function[23241]
<?>.wasm-function[23239]
<?>.wasm-function[16290]
<?>.wasm-function[16289]
<?>.wasm-function[20540]
<?>.wasm-function[20547]
<?>.wasm-function[16963]
<?>.wasm-function[16980]
<?>.wasm-function[16981]
<?>.wasm-function[23360]
<?>.wasm-function[23365]
wasm-stub
(anonymous function) (build.framework.js.gz:10:280926)
callMain (build.framework.js.gz:10:321846)
doRun (build.framework.js.gz:10:322288)
run (build.framework.js.gz:10:322457)
runCaller (build.framework.js.gz:10:321495)
removeRunDependency (build.framework.js.gz:10:16967)
(anonymous function) (build.framework.js.gz:10:1933)
doCallback (build.framework.js.gz:10:91430)
done (build.framework.js.gz:10:91586)
(anonymous function) (build.framework.js.gz:10:85236)`

The app still runs, and the objects are loaded and visible, however those warnings and errors appear. I am also experiencing intermittent crashes while loading the WebGL app saying A problem repeatedly occurred on ... that I think might be caused by so many errors appearing, but I don't know for sure.

It happens in iOS and WebGL. I have not tried any other platforms. I have also tried the ImportMesh sample and it also produces these errors.

I'm using Unity 2022.3.5f1 Intel on a MacBook Pro M2 Max
I installed the USD package by name com.unity.formats.usd and it is version 3.0.0-exp.4

Here is a GitHub repo of a project to reproduce the errors: https://github.com/Process-Solutions-Group/SerializationBugReport

Here is a hosted WebGL build of that project: https://pages.myblendedlearning.org/sites/usdtest/

I'm willing to help with debugging/fixing, if someone can help point me to the right places to start looking.

@vickycl
Copy link
Collaborator

vickycl commented Sep 13, 2023

Hi @joshbaran! Thank you for reporting.

I think the core of the problem is that the USD plugin is not built for runtime, so the scripts are not present in builds. Hopefully you can get past this by 'detaching' the USD components after importing the Game Objects?

I will make a note to review the behaviour of these scripts so that we can stop the errors from happening. Let me know if you still have issues after detaching them.

Thanks again!

@vickycl vickycl changed the title Missing script and Serialization layout errors in built products Missing script and Serialization layout errors in built products [USDU-487] Sep 13, 2023
@joshbaran
Copy link
Author

It works to remove the components. There are no errors/warnings in the builds then. However, that is not a good solution since after doing that, I can't reimport them from USD if they change. I can delete and import again, but that loses all changes like position and rotation that I made to set up the scene. It is also a very tedious task to remove all the components. This example model is not bad, but I have models with hundreds of components. I could write a script to do it for me, but that still leaves the reimport issue.

This seems like a task that the build should perform. And I'm thinking it actually is half-performed during the build: The objects are serialized without the components, but their definitions retain them, causing the mismatch. The build should remove them from both.

Again, I'm willing to help fix this, I just need some direction on where to look in the code.

@vickycl
Copy link
Collaborator

vickycl commented Sep 15, 2023

I've just tested it out on my MacBook (admittedly intel, not M2) and I can't reproduce in just an OSX player build. It might take a while for us to be able to check this on iOS. If you're keen to investigate yourself, I would assume that the scripts in Runtime/Scripts/Behaviours, especially UsdAsset.cs would be the cause of the missing script error. I see the assembly definition at Packages/com.unity.formats.usd/Runtime/Unity.Formats.USD.Runtime.asmdef doesn't include the scripts on the platforms you're using, because the USD APIs aren't supported there. You could try enabling your platforms in there, and then wrap the code in the scripts with #if UNITY_EDITOR. That should mean the expected serialised types are present, but the code that won't compile there isn't being compiled. Let me know if that makes sense, and if that works as a workaround for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants