NullReferenceException on AD.DefaultGlobalVariables

Mon 10. Apr 2017, 18:19

Hello, I'm having an issue that keeps happening to me and my coworker.

I'm doing almost exactly what you are doing in the Maniac Manfred demo app :

Code: Select all
private void OnEnable()
{
    ArticyDatabase.DefaultGlobalVariables.Notifications.AddListener("Inventory.*", OnVarChanged);
}

private void OnDisable()
{
    ArticyDatabase.DefaultGlobalVariables.Notifications.RemoveListener("Inventory.*", OnVarChanged);
}


However, sometimes I'm getting a NullReferenceException when accessing both of these calls. I looked at it and it looks like that DefaultGlobalVariables is indeed null. However, how does that happen ? I've been able to fix the issue with reimporting the data. Any idea on why this would work for a while and then suddenly, I'm getting this issue ? FYI, my imported data as a .articyu3d file has not been updated for a few days.
Attachments
Articy_Null_GlobalVariables.PNG
Articy_Null_GlobalVariables.PNG (27.53 KiB) Viewed 20137 times
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Mon 10. Apr 2017, 18:48

Hi thewalrusnp,

that is indeed odd. I had this problem a couple of times while developing the plugin, but managed to fix it before we released the plugin and never encountered it after then.
While it is working fine for me and a couple of other users that i know of, i think it must be something specific to how you use the plugin or how you and your team are working with it.
This problem happens because the unity serialization did not manage to fully serialize/deserialize the articydatabase, which is weird because a couple of other objects inside the database (like the fragments) are working fine and are properly set.

So a couple of questions:

  • Do you use any kind of source management? Like SVN, Git etc.
  • If yes, do you ignore any files generated by the plugin?
  • Does this happen after closing/reopening the project or switch between playmode/editmode?
  • Are you using the attribute ExecuteInEdit mode on those classes with your OnEnable/OnDisable calls?
  • Are you calling anything articy related in any Awake method?

Oh and please check if you are using the newest version of the plugin, currently we don't have an notification system to tell when a new version is up(still awaiting unity asset store approval).
But you can always get the newest version here.

Sorry that this happens but i will try my best to find a solution with you!

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: NullReferenceException on AD.DefaultGlobalVariables

Mon 10. Apr 2017, 19:17

Hello Nico,

Thanks for the quick answer!

Do you use any kind of source management? Like SVN, Git etc.

We do use Collab that is the built-in source management provided by Unity.
If yes, do you ignore any files generated by the plugin?

No we don't. We submit generated files since we could not ignore files in the version of Unity we were using. It is a problem since ArticyScriptFragment.cs and InputPin.cs do get submitted everytime someone is reimporting data, even if no change has been made in the articyu3d file.
Does this happen after closing/reopening the project or switch between playmode/editmode?

I'm not sure about that one. I haven't been able to find out a clear pattern.
Are you using the attribute ExecuteInEdit mode on those classes with your OnEnable/OnDisable calls?

No we are not, I never used that attribute.
Are you calling anything articy related in any Awake method?

No.

If you need more information, just ask me. I just looked at the ArticyScriptFragment.cs file and since I reimported the data, I do see difference in the ArticyCodeGenerationHashAttribute and also for the Script_***() methods. Does it mean that when my coworker reimport data and submit ArticyScriptFragment.cs, upon synching on my side the deserialize won't work ?
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Tue 11. Apr 2017, 02:56

For your information, I got this problem again tonight. While reverting some script files I had (unrelated to Articy:Draft), I decided to shut Unity down and restart it as it was stuck in a compile loop. Upon lauching the game in editor mode, I got back the NullReferenceException from my call to ArticyDatabase.DefaultGlobalVariables. I decided to try importing data again using the Import articy:draft export file, alt tabbed to do something else and when I got back to Unity, I was stuck at the Importing Articy data window displaying Importing Object data. I waited for a few minutes, but I was still in that state and I had to cancel the import. I tried again, same result. I shut down Unity again and restarted it. This time, it worked.
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Tue 11. Apr 2017, 09:49

Hi thewalrusnp,

Your additional information and investigation is greatly appreciated!

Could you please tell me what unity and what plugin version you are using? The plugin version can be found in the bottom of the DatabaseView, in the same area of the inspector.

While investigating your bug, i found another one that is very similar. In my case the Hierarchy object is always null after a closing and reopening unity. To check that, could you send me a screenshot of the the inspector of the articy database.
To do that, navigate to Assets/Generated/Resources/ArticyDatabase.asset. Now you usually see the normal database view, but you need to switch the inspector to debug. You can find this in the tabbar of the inspector the icon on the far right. To switch back later, just check normal.

inspector_database.png
inspector_database.png (29.98 KiB) Viewed 20119 times


If possible, could you try to check if this problem usually occurs after a recent reimport of the articy:draft export? One of my ideas is that a missing save call is causing this, so you reimport, close the editor and the change is not properly stored. But if you work fine for longer periods of time, no reimport, saving the project, closing and reopening it and its null again, then it must be something else.

We do use Collab that is the built-in source management provided by Unity.


While i doubt that this could be a problem its at least something thats different from my machine. I will try to check on that.

I just looked at the ArticyScriptFragment.cs file and since I reimported the data, I do see difference in the ArticyCodeGenerationHashAttribute and also for the Script_***() methods. Does it mean that when my coworker reimport data and submit ArticyScriptFragment.cs, upon synching on my side the deserialize won't work ?


Don't worry that is normal. But it is true that this is annoying when working with any source control managment software, for the next release of the plugin i plan to address that by modifying how the generated folder is structured to allow completely setting on folder on ignore and not commit those changes at all.

As you can see i'm still a bit in the dark, so any bits of help are welcome! :)

Thank you for your help to fix this bug!

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: NullReferenceException on AD.DefaultGlobalVariables

Tue 11. Apr 2017, 16:47

Hello,

I'm currently on Unity 5.6.0f3 and I am using plugin version 1.0.0.31187. I attached a screenshot of the current ArticyDatabase debug inspector view as requested. I will attach a screenshot of the database if I get the error again. I will also try to find a pattern when this is happening, since I'm really not sure of the exact steps to reproduce it. I got it twice yesterday. I will let you know once I have this issue again.
Attachments
Articy_Capture_2.PNG
Articy_Capture_2.PNG (18.5 KiB) Viewed 20113 times
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Wed 12. Apr 2017, 01:25

Hello,

I just reproduced the problem. Here is how I was able to get it. First of all, I was running the game perfectly from the editor. Before submitting my feature through Collab, I reverted some files. Upon reverting some of those files, Unity got into a compile loop (the compile never stopped). I had to close Unity as it was impossible to run the game again. Upon reopening the project, I ran back the game through the editor and I got the NullReferenceException. I went to see the ArticyDatabase file in Debug mode and found out that DefaultGlobalVariables was not linked anymore. Also, when pressing the link icon, I could not find any object of that type. I attached the screenshot I took.

I should try to see if I get this compile error loop when reverting files using Collab. If I remember correctly, we never had this problem with Unity prior to install the plugin around the release date. Since we upgraded from Unity 5.5 to 5.6 beta around the same time, we thought that maybe it was an issue with Collab. It is however clear that when I shutdown Unity to stop this compile error, the DefaultGlobalVariables object is not linked anymore.

Also interesting is the fact that upon seeing that the DefaultGlobalVariables wasn't linked, I tried to reimport Articy data. It got stuck in the "Importing Object data" step. I had to cancel the Articy import process and Unity went back into a compile loop (icon was always rotating). I did retry a second time the reimport step : same result. To be able to get out of this never ending loop, I had to shutdown Unity, restart it, launch the project and, before doing anything else, click on reimport Articy data. This time, the whole step when through and DefaultGlobalVariables was relinked.

I hope this can help you in your findings.
Attachments
Articy_3_Capture.PNG
Articy_3_Capture.PNG (51.51 KiB) Viewed 20110 times
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Wed 12. Apr 2017, 01:45

Here is a step by step summary :

1) Game is working fine from editor.
2) I revert some unrelated files to Articy using Collab -> that is triggering a compile.
3) The compile never stops -> Shutdown Unity and restart it.
4) I launch the game through the editor -> Get NullReferenceException on DefaultGlobalVariables as it is not linked in ArticyDatabase.
5) I click on Reimport Articy data -> Get stuck in "Importing Object data".
6) Canceling importing Articy data -> Triggers a compile that never stop.
7) I click on Reimport Articy data again -> Get stuck in "Importing Object data".
8) Canceling importing Articy data again -> Triggers a compile that never stop.
9) Shutdown, restart Unity and click on Reimport Articy data -> Import step is working, compiling is working and DefaultGlobalVariables is now linked.
thewalrusnp
 
Posts: 12
Joined: Thu 23. Mar 2017, 17:32

Re: NullReferenceException on AD.DefaultGlobalVariables

Wed 12. Apr 2017, 09:10

Hi,

ok i did a quick test with collab, which worked fine, but i will test it more thoroughly today. One thing you could do for me is, copy the ArticyDatabase.asset file after a successfull import and after the null reference. That way we can diff both files and see why the global variables is gone from the database.

You can send me those files to my email if you want: nico.probst@nevigo.com

i keep you updated on my collab tests!

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: NullReferenceException on AD.DefaultGlobalVariables

Wed 12. Apr 2017, 10:43

Further testing:

  • I found a rather large bug regarding sub assets and fixed it, will be available in the next version.
  • I can reproduce the issue with collab, reverting, reopening and the global variables are empty, but have yet to find out why this is happening.
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Next

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 11 guests

Who We Are
Contact Us
Social Links