0

I have a system multithreaded across Swift, C++ and Objective-C.

I've noticed that when scrolling a scrollview, the UI can totally deadlock. OpenGL is still rendering and updating correctly and the audio thread is still running, but I cannot interact with the UI.

This only happens when scrolling the scrollview, especially when decelerating.

Is there a way to change the runloop mode for the scrollview tracking or a different way to fix this issue?

I profiled with Time Profiler to check for thread waiting indicators and I cannot determine what is causing the deadlock.

EDIT:

After additional testing, it looks like collectionviews and tableviews are also causing the deadlock.

How can this be debugged?

some_id
  • 29,466
  • 62
  • 182
  • 304
  • What are you trying to display in your scroll view? – Rhuari Glen Sep 01 '16 at 15:49
  • In the scroll view I have a number of UIView subviews. The deadlock is being caused in any scrollview, the tableviews and the collection views too. All displaying custom cells, nothing that could specifically cause the deadlock. – some_id Sep 01 '16 at 15:50
  • I found that there was a severe lag in my tableview scrolling when I was setting `tableview.estimatedRowHeight` to a large value, lowering that solved my issues. As for your scrollview, is the memory okay? No leaks? – Rhuari Glen Sep 01 '16 at 16:00
  • 1
    Have you had a look at this answer? Seems similar to the issues you have experiencing. http://stackoverflow.com/questions/4876488/animation-in-opengl-es-view-freezes-when-uiscrollview-is-dragged-on-iphone – Rhuari Glen Sep 01 '16 at 16:04
  • Thanks for the link, its kind of reverse to what I am experiencing, but put me on the right path. Cheers! – some_id Sep 01 '16 at 16:28

1 Answers1

0

For anyone who might come across the same issue.

I had C++ code that was calling a completion block into Swift. The completion block was dispatch_asyncing back to the main thread at a high rate, in order for the setNeedsDisplay() to trigger render updates on a GLKView.

This led to a UI deadlock only when a scrollview was scrolled.

I fixed this by using a CADisplayLink instead, which just calls setNeedsDisplay() on the GLKView if certain properties are true.

some_id
  • 29,466
  • 62
  • 182
  • 304