Author Topic: Error on quitting Android application  (Read 8770 times)

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Error on quitting Android application
« 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.
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on quitting Android application
« Reply #1 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.         }

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: Error on quitting Android application
« Reply #2 on: January 18, 2014, 03:01:35 AM »
Does not help. It seems, that drawCall instance exists, but its gameobject is already terminated..
I'm a busy man... I have places to go,monsters to kill...

adb

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Error on quitting Android application
« Reply #3 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)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on quitting Android application
« Reply #4 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.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Error on quitting Android application
« Reply #5 on: January 24, 2014, 08:24:32 AM »
Shouldn't it be if (dc!=null) or does if (dc) work in C# aswell?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Error on quitting Android application
« Reply #6 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.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Error on quitting Android application
« Reply #7 on: January 24, 2014, 09:46:52 AM »
Your learn something new every day :)