Disabling Domain Reload – MissingReferenceException when calling agent.name

Forums 💬 NodeCanvas ⚙️ Support Disabling Domain Reload – MissingReferenceException when calling agent.name

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #15345
    ledshok
    Participant

      I regularly use Unity with Domain Reload disabled under Project Settings. Normally this speeds up entering play mode with no obvious downside.

      However, I added the following code within a custom ConditionTask:

      Debug.Log($”Agent: {agent.name}”);

      and I now get the following error (after entering play mode and hitting that line of code, stopping play mode, and entering play mode a second time and hitting the same line of code again):

      MissingReferenceException: The object of type ‘FSMOwner’ has been destroyed but you are still trying to access it.
      Your script should either check if it is null or you should not destroy the object.

      Interestingly, if I change the code to simply refer to agent (instead of agent.name) I don’t get the error. If I renable Domain Reload I don’t get the error either.

      #15356
      Gavalakis
      Keymaster

        Hello,

        Hmm. This is weird. I always have domain reload disabled as well (even when developing NC for the most part). I tried replicating the issue you mentioned, but I wasn’t really able to. Can you replicate this on a simple graph and let me know how? Also please let me know what version you are using. Thank you.

        #15355
        ledshok
        Participant

          Yes, I’ve created a simple test project (with only NC and a couple of classes) and replicated the issue. What’s the easiest way to get it to you (and what folders should I include)?

          Package Manager tells me I’m on NodeCanvas v3.2.6, and Unity is v2022.3.0f (LTS).

          #15354
          ledshok
          Participant

            Here it is attached with just the Library folder removed (which I believe isn’t needed).

            #15353
            Gavalakis
            Keymaster

              Please don’t publicly distribute files including NodeCanvas … I deleted the attachment.
              I will look into it and let you know.

              #15352
              ledshok
              Participant

                Oh sorry! I didn’t even think. Apologies.

                #15351
                ledshok
                Participant

                  Did you get anywhere with the investigation?

                  #15350
                  Gavalakis
                  Keymaster

                    Hello there,
                    I think there is something missing from the reproduction project you’ve sent because clicking the button does not actually fire up any events (I presume it is supposed to? ). Can you double-check and let me know? If you want to send me any files please do so to support_AT_paradoxnotion.com

                    #15349
                    ledshok
                    Participant

                      Sent.

                      #15348
                      ledshok
                      Participant

                        Not sure if you’ve had a chance to investigate this, but I think it may be related to OnDisable not always being called for my custom ConditionTask.

                        So in OnEnable it subscribes to an event, but if OnDisable isn’t called the event isn’t unsubscribed. On entering play mode again, I’ll see multiple subscribers to my event, only one of which will have the agent value set.

                        Hope that helps.

                        EDIT: at a basic level, am I correct in thinking that my custom ConditionTask’s OnEnable and OnDisable methods should be called an equal number of times during a single play mode session (from startup to quit)? If I stick Debug.Log statements in each I’m getting a higher count of OnEnable than OnDisable…

                        #15347
                        Gavalakis
                        Keymaster

                          Hello again,

                          OnEnable and OnDisable should indeed be called an equal amount of times, yes. There are also some assertions to check this. In the context of an FSM, Condition Tasks on transitions should be Enabled when their FSM State node is entered, and should be Disabled when that FSM State node is exited.
                          I tried to replicate a case where OnEnable is called more times than OnDisable, but I wasn’t really able to do so.
                          Can you please tell or show a minimal reproduction graph that this happens?

                          Than you.

                          #15346
                          ledshok
                          Participant

                            I was just in the process of sending you my example project (even captured screenshots showing it step by step), but just before I zipped it up I thought I should try completely deleting the ParadoxNotion folder from the project and reimporting it. Now I can’t replicate the issue!

                            So apologies for wasting your time. I’m guessing somewhere along the line an upgrade between NodeCanvas versions didn’t work correctly and I was left with a ‘non-standard’ build. In the future I’ll be sure to delete and re-import when installing new versions.

                          Viewing 12 posts - 1 through 12 (of 12 total)
                          • You must be logged in to reply to this topic.