Author Topic: Bug report: Crash on iOS when opening native view  (Read 3794 times)

peter

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Bug report: Crash on iOS when opening native view
« on: March 13, 2014, 03:33:48 AM »
Hi,

We've fund a bug in NGUI 3.5.3 that wasn't present in older versions, and it doesn't seem to be fixed in 3.5.4.

The program will crash on iOS if you create an UIButton that opens a native iOS view in its OnClick() method. We've tested this with the native Tweet Composer, the Twitter SDK's login view and GameCenter's achievements view. Any view will probably do.

The crash happens in UICamera on line 1478:

  Notify(currentTouch.pressed, "OnClick", null);
  if (currentTouch.clickTime + 0.35f > time)

With this exception:

NullReferenceException: A null value was found where an object instance was required.
at UICamera.ProcessTouch (Boolean pressed, Boolean unpressed) [0x00559] in
Assets/NGUI/Scripts/UI/UICamera.cs:1478

The currentTouch is probably invalid after a new view has been opened. Is it set to null in OnApplicationPause() maybe?

Our current workaround is to remember the click and delay the opening of the view until the next frame when there're no touches left on screen.

We're using Unity 4.3.4 and tested this with XCode 5.0 and 5.1.

Email me if you want a small test project that reproduces the problem.

Any help is very much appreciated. Thanks.
« Last Edit: March 13, 2014, 05:15:21 AM by peter »

peter

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Bug report: Crash on iOS when opening native view
« Reply #1 on: March 13, 2014, 04:31:09 AM »
A note:

We're using Prime31's plugins (version 2014-02-25) to open all the native views. It's possible that there's a problem with them that ruins the touches. Prime31's code does this when opening for example the Tweet Composer:

   // Show the tweet sheet
   UnityPause( true );
   [UnityGetGLViewController() presentModalViewController:tweetSheet animated:YES];

Can UnityPause( true ) be an issue here?

romeo_ftv

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 4
    • View Profile

peter

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Bug report: Crash on iOS when opening native view
« Reply #3 on: March 13, 2014, 08:14:57 AM »
http://www.tasharen.com/forum/index.php?topic=8545.0

Thanks. That works. Maybe this should be added in the next update of NGUI?