Author Topic: Crash on iOS on UIPanel  (Read 10599 times)

frarees

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Crash on iOS on UIPanel
« on: March 01, 2013, 07:00:19 AM »
I'm getting those errors:

  1. NullReferenceException: A null value was found where an object instance was required.
  2.   at UISprite.OnFill (.BetterList`1 verts, .BetterList`1 uvs, .BetterList`1 cols) [0x000e9] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/UI/UISprite.cs:353
  3.   at UIWidget.UpdateGeometry (UnityEngine.Matrix4x4& worldToPanel, Boolean parentMoved, Boolean generateNormals) [0x0003b] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/Internal/UIWidget.cs:424
  4.   at UIPanel.UpdateWidgets () [0x0002c] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/UI/UIPanel.cs:834
  5.   at UIPanel.LateUpdate () [0x000be] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/UI/UIPanel.cs:969
  6.  
  1. NullReferenceException: A null value was found where an object instance was required.
  2.   at UIDrawCall.Set (.BetterList`1 verts, .BetterList`1 norms, .BetterList`1 tans, .BetterList`1 uvs, .BetterList`1 cols) [0x00283] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/Internal/UIDrawCall.cs:297
  3.   at UIPanel.Fill (UnityEngine.Material mat) [0x00133] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/UI/UIPanel.cs:927
  4.   at UIPanel.LateUpdate () [0x00101] in /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/UI/UIPanel.cs:979
  5.  
  6. (Filename: /Users/frarees/Documents/xmap-client/Assets/NGUI/Scripts/Internal/UIDrawCall.cs Line: 297)
  7.  
As a hint, I'm using NGUI 2.3.4 and HUD Root. Some UIPanels have checked the depth pass (if it helps).

EDIT: It does work on editor without a problem (long testing on this), and we get it working on some of our iPads, some of them make it crash and some others not. It's very random, but I see that it's more reproducible on iPad 4 (retina).

Any help? Thanks!
« Last Edit: March 01, 2013, 08:55:29 AM by frarees »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Crash on iOS on UIPanel
« Reply #1 on: March 01, 2013, 10:02:23 AM »
Uh... if mPanel is null in the OnFill function then something went terribly wrong. Likewise if the mesh filter is gone in the UIDrawCall, then something exploded. How did you get to that state? What are you doing to cause it? How do you hide/show your UI?

frarees

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Crash on iOS on UIPanel
« Reply #2 on: March 01, 2013, 10:52:33 AM »
We have a hierarchy that expands like this:

- UIRoot
-- Camera
--- Panel
---- Panel + Managers (Parent containing shop stuff. That enables or disables children. Using NGUITools.SetActive)
----- Anchor + Collider (Window Anchor)
------ Panel + DragablePanel (Current Window. When we navigate between windows, we disable this GO and enable the corresponding window GO, and do some logic)
------- Grid + Anchor (Grid that contains the set of buttons)
-------- DragPanelContents + More Managers (Shop Button)
--------- Sprite (All the UI elements that form a Shop Button)

We're not instantiating and destroying those, just enabling/disabling.
If you need I can send you a prefab containing those objects and their settings, if that could help.

frarees

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Crash on iOS on UIPanel
« Reply #3 on: March 05, 2013, 06:31:58 AM »
It was a problem of dynamically switching atlasses (to support several resolutions: SD, HD & Ultra). Somehow it screwed things up. Here's the code we were using:

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. /// <summary>
  6. /// Atlas changer dependant on the device's resolution.
  7. /// </summary>
  8. /// <description>
  9. /// This is a script that changes the reference atlas in the UI to any of the
  10. /// other atlasses based on the device's resolution, so that the pixel
  11. /// perfectness is not lost.
  12. /// </description>
  13. /// <remarks>
  14. /// This script is meant to be attached to the UIRoot object.
  15. /// </remarks>
  16. public class ResolutionSetup : MonoBehaviour
  17. {
  18.         private UIRoot uiRoot;
  19.         public UIAtlas[] usedAtlasses;
  20.         public UIAtlas[] lowResAtlasses;
  21.         public UIAtlas[] highResAtlasses;
  22.        
  23.         /// <summary>
  24.         /// Awake this instance.
  25.         /// </summary>
  26.         private void Awake()
  27.         {
  28.                 uiRoot = this.GetComponent<UIRoot>();
  29.                
  30.                 if (lowResAtlasses.Length != highResAtlasses.Length)
  31.                 {
  32.                         Debug.LogWarning("Low and high res atlasses do not fit");
  33.                         return;
  34.                 }
  35.  
  36.                 if (DeviceHelper.IsHighRes())
  37.                 {
  38.                         // Handle high res atlas
  39.                         for (int i = 0; i < usedAtlasses.Length; i++)
  40.                         {
  41.                                 usedAtlasses[i].replacement = highResAtlasses[i];
  42.                         }
  43.                 }
  44.                 else
  45.                 {
  46.                         // Handle low res atlas
  47.                         for (int i = 0; i < usedAtlasses.Length; i++)
  48.                         {
  49.                                 usedAtlasses[i].replacement = lowResAtlasses[i];
  50.                         }
  51.                 }
  52.         }
  53.        
  54.         /// <summary>
  55.         /// Raises the disable event.
  56.         /// </summary>
  57.         private void OnDisable()
  58.         {
  59.                 if (DeviceHelper.IsHighRes())
  60.                 {
  61.                         // Prevent replacement from sticking.
  62.                         // In low res, there is no atlas change.
  63.                         for (int i = 0; i < highResAtlasses.Length; i++)
  64.                         {
  65.                                 usedAtlasses[i].replacement = lowResAtlasses[i];
  66.                         }
  67.                 }
  68.         }
  69.  
  70.         /// <summary>
  71.         /// Start this instance.
  72.         /// </summary>
  73.         private void Start()
  74.         {
  75.                 uiRoot.manualHeight = uiRoot.minimumHeight = uiRoot.maximumHeight = DeviceHelper.Height();
  76.         }
  77. }

juhaRMD

  • Guest
Re: Crash on iOS on UIPanel
« Reply #4 on: March 05, 2013, 09:54:54 AM »
It was a problem of dynamically switching atlasses (to support several resolutions: SD, HD & Ultra). Somehow it screwed things up.

We have exactly the same situation: we get a crash in m_UIPanel_UpdateWidgets on an iPad3 as soon as a simple panel with label and a button is activated, after atlas switching has been applied. This panel was being deactivated (using NGUITools.SetActive(gameObject, false)) at Start(), and it crashed as soon as it was reactivated. We were able to fix the crash by moving the initial deactivation from Start() to Update(). Crash does not occur if atlas switching is disabled. Does anybody know what is going on?

The atlas switching code is from http://www.tasharen.com/forum/index.php?topic=832.0

(NGUI 2.3.4)

adam718

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 60
    • View Profile
Re: Crash on iOS on UIPanel
« Reply #5 on: March 05, 2013, 10:24:12 AM »
That occurred in mine. (Windows/Android/iOS,...)
But I couldn't figure it out what's wrong.
I am sad that I can't tell Aren the reason of error now.
« Last Edit: March 05, 2013, 10:37:48 AM by adam718 »