Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AGB on January 16, 2014, 09:55:13 AM

Title: Error on quitting Android application
Post by: AGB on January 16, 2014, 09:55:13 AM
When calling Application.Quit(), always getting:

INFO/Unity(14020): NullReferenceException
        at UnityEngine.Component.get_gameObject () [0x00000] in <filename unknown>:0
        at UIDrawCall.Destroy (.UIDrawCall dc) [0x00000] in <filename unknown>:0
        at UIPanel.OnDisable () [0x00000] in <filename unknown>:0
        (Filename:  Line: -1)
INFO/Unity(14020): NullReferenceException
        at UnityEngine.Component.get_gameObject () [0x00000] in <filename unknown>:0
        at UIDrawCall.Destroy (.UIDrawCall dc) [0x00000] in <filename unknown>:0
        at UIPanel.OnDisable () [0x00000] in <filename unknown>:0
        (Filename:  Line: -1)


Is there any workaround? Never got this in Editor.
Title: Re: Error on quitting Android application
Post by: ArenMook on January 16, 2014, 11:40:59 PM
Can't say I've seen that one. It looks like your draw calls get destroyed before the panel for some curious reason.

Change UIPanel.OnDisable to this:
  1. protected override void OnDisable ()
  2.         {
  3.                 for (int i = 0; i < drawCalls.size; ++i)
  4.                 {
  5.                         UIDrawCall dc = drawCalls.buffer[i];
  6.                         if (dc != null) UIDrawCall.Destroy(dc);
  7.                 }
  8.                 drawCalls.Clear();
  9.                 list.Remove(this);
  10.                
  11.                 if (list.size == 0)
  12.                 {
  13.                         UIDrawCall.ReleaseAll();
  14.                         mUpdateFrame = -1;
  15.                 }
  16.                 base.OnDisable();
  17.         }
Title: Re: Error on quitting Android application
Post by: AGB on January 18, 2014, 03:01:35 AM
Does not help. It seems, that drawCall instance exists, but its gameobject is already terminated..
Title: Re: Error on quitting Android application
Post by: adb on January 21, 2014, 01:55:31 PM
I'm having what I guess is the same issue, but on Windows Phone 8. It happens when the application Quits, every single time. Here is the exception thrown. It appears to be internal to Unity when resolving dc.gameObject in Destroy().

First-chance exception at 0x77C81ECF in TaskHost.exe: Microsoft C++ exception: Platform::NullReferenceException ^ at memory location 0x0416F4F8.

Exception: External component has thrown an exception.
Type: System.Runtime.InteropServices.SEHException
Module: UnityEngineProxy
InnerException: <No Data>
AdditionalInfo:Invoking UIPanel::OnDisable method with argument count: 0
   at UnityEngineProxy.InternalCalls.Component_CUSTOM_InternalGetGameObject(Object self)
   at UnityEngine.Component.get_gameObject()
   at UIDrawCall.Destroy(UIDrawCall dc)
   at UIPanel.OnDisable()
   at lambda_method(Closure , Object , Object[] , Int32 )
   at WinRTBridge.MethodTools.InvokeMethod(Object instance, Int32 methodIndex, Object[] args)
Title: Re: Error on quitting Android application
Post by: ArenMook on January 22, 2014, 04:28:52 AM
Sounds like some bug in Unity I need to make a work-around for. Try changing UIDrawCall.Destroy to this:
  1.         static public void Destroy (UIDrawCall dc)
  2.         {
  3.                 if (dc)
  4.                 {
  5.                         if (Application.isPlaying)
  6.                         {
  7.                                 if (mActiveList.Remove(dc))
  8.                                 {
  9.                                         NGUITools.SetActive(dc.gameObject, false);
  10.                                         mInactiveList.Add(dc);
  11.                                 }
  12.                         }
  13.                         else
  14.                         {
  15.                                 mActiveList.Remove(dc);
  16.                                 NGUITools.DestroyImmediate(dc.gameObject);
  17.                         }
  18.                 }
  19.         }
If that doesn't work, try adding a try/catch block around the whole thing.
Title: Re: Error on quitting Android application
Post by: breakmachine on January 24, 2014, 08:24:32 AM
Shouldn't it be if (dc!=null) or does if (dc) work in C# aswell?
Title: Re: Error on quitting Android application
Post by: ArenMook on January 24, 2014, 08:40:58 AM
if (unity object) checks not only the null, but also if the object is in the queue to be destroyed.
Title: Re: Error on quitting Android application
Post by: breakmachine on January 24, 2014, 09:46:52 AM
Your learn something new every day :)