Author Topic: UIPopupList closes immediately at low frame-rates (PC).  (Read 1591 times)

charliehelman

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 16
    • View Profile
UIPopupList closes immediately at low frame-rates (PC).
« on: January 16, 2015, 07:21:48 PM »
Hi Aren,

As suggested in the title, we discovered an issue where our Popup Lists close themselves right after being opened when the FPS drops below ~10 frames. Obviously, we're trying to fix the performance issues causing the game to run so sluggishly, but in the meantime I wanted to at least make sure you knew about the issue.

The affected popup lists happen to be for our graphical settings. We're finding users will set the options too high, then be unable to interact with the popup lists due to the ensuing framerate problems. Kind of hilarious, actually.

Anyway, have you encountered this before? Any ideas about working around it?

charliehelman

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 16
    • View Profile
Re: UIPopupList closes immediately at low frame-rates (PC).
« Reply #1 on: January 16, 2015, 10:16:42 PM »
Couple hours of debugging under my belt, here are my findings:

Forcing unity to run at a target frame-rate of 5 frames. Long story short, we seem to run into an unexpected case in UICamera's ProcessMouse() function where Intput.GetMouseButtonDown and Input.GetMouseButtonUp are both evaluated true in the same frame. I'm not sure if this is a normal case, or even an edge case at a normal frame-rate.

The logic in ProcessTouch handles both pressed and unpressed inclusively. The logic for pressed starts a coroutine, but the logic for unpressed runs before that coroutine can continue, so (seemingly) the mSelectedObject and mNextSelection objects are garbage values by the time the coroutine has time to deal with them. And thus, the coroutine closes the popuplist at the end of the frame.

My current fix is simply to make unpressed always evaluate to false if pressed is true. However, I'm not sure if this is a good idea. It does cause the popups to work fine at the low framerate, and I wasn't able to find anything else that breaks due to the change (though I only tested briefly).

What do you think?

The code in UICamera's ProcessMouse() function, with my edit noted:
  1.         // Process all 3 mouse buttons as individual touches
  2.                 for (int i = 0; i < 3; ++i)
  3.                 {
  4.                         bool pressed = Input.GetMouseButtonDown(i);
  5.                         bool unpressed = Input.GetMouseButtonUp(i);
  6.                        
  7.                         if (pressed) unpressed = false; // CHARLIE'S (PROBABLY TERRIBLE) EDIT.
  8.  
  9.                         if (pressed || unpressed) currentScheme = ControlScheme.Mouse;
  10.  
  11.                         ... snip ...
  12.        
  13.                         // Process the mouse events
  14.                         ProcessTouch(pressed, unpressed);
  15.                         currentKey = KeyCode.None;
  16.                 }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList closes immediately at low frame-rates (PC).
« Reply #2 on: January 18, 2015, 04:12:46 AM »
I recently made changes to address the ability to press and release in the same frame, so the next version of NGUI should already probably fix it for you. I'll release it shortly.