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

CodeGen issue when upgrading from 1.3.1 to 1.5.1 #2605

Closed
ashkan-saeedi-mazdeh opened this issue Jul 2, 2023 · 5 comments
Closed

CodeGen issue when upgrading from 1.3.1 to 1.5.1 #2605

ashkan-saeedi-mazdeh opened this issue Jul 2, 2023 · 5 comments
Labels
stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report

Comments

@ashkan-saeedi-mazdeh
Copy link

Description

After upgrading from 1.3.1 to 1.5.1 I get this error in the console

Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error  - System.NullReferenceException: Object reference not set to an instance of an object.||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)

Reproduce Steps

I don't have any reproduction steps other than the package upgrade but I don't know which part of our codebase is triggering this. The project is huge and we probably cannot send it due to company policy.

Is there any way I can get a better stack trace?

Actual Outcome

The codegen has this exception and the project cannot run.

Expected Outcome

A smooth upgrade or an error message saying what serialization code should change.

Environment

  • OS: [Windows 10]
  • Unity Version: [2022.3]
  • Netcode Version: [1.5.1]

Additional Context

I'll try to find what part of our serialization code might be causing this but it would be good if there was a way to see where it breaks or what serialization code-gen changes happend.
And again this is the error log

Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error  - System.NullReferenceException: Object reference not set to an instance of an object.||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)||   at System.Collections.Generic.List`1.ForEach(Action`1 action)||   at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)

I noticed one code-gen feature is added for initialization and that might be the cause? I assume there is no regression in the other serialization codes of course.

@ashkan-saeedi-mazdeh ashkan-saeedi-mazdeh added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Jul 2, 2023
@MjKkaya
Copy link

MjKkaya commented Jul 5, 2023

I got same error from 1.4.0 to 1.5.1
Unity 2022.3.4f1 and 2021.3.28f1
MacOS Ventura 13.4.1

Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: (0,0): error - System.NullReferenceException: Object reference not set to an instance of an object.| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass7_0.<Process>b__1(TypeDefinition b)| at System.Collections.Generic.List1.ForEach(Action1 action)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly) at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.GenerateVariableInitialization(TypeDefinition type)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.ProcessNetworkBehaviour(TypeDefinition typeDefinition, String[] assemblyDefines)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.<>c__DisplayClass7_0.<Process>b__1(TypeDefinition b)| at System.Collections.Generic.List1.ForEach(Action1 action)| at Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP.Process(ICompiledAssembly compiledAssembly)

@ashkan-saeedi-mazdeh
Copy link
Author

I found out what was the problem in our case. We had a class Singleton<T>:NetworkBehaviour class which we were not even using and it was causing this.

@MjKkaya
Copy link

MjKkaya commented Jul 5, 2023

I found out what was the problem in our case. We had a class Singleton<T>:NetworkBehaviour class which we were not even using and it was causing this.

Yes it is! The answer is saved me!!
Thanks a lot!

@PitouGames
Copy link
Contributor

Duplicate of #2592, a fix is waiting to be merged: #2603

@ashkan-saeedi-mazdeh
Copy link
Author

I'll close this since it is a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

3 participants