Search code examples
iosopengl-esuiscrollviewscrollcadisplaylink

UIScrollView broken and halts scrolling with OpenGL rendering (related CADisplayLink, NSRunLoop)


Solution note, Not a question.

UIScrollView suspends OpenGL rendering by preventing firing CADisplayLink tick when CADisplayLink registered with NSDefaultRunLoopMode.

But, if you use NSRunLoopCommonModes to solve this, UIScrollView will halt scrolling at burst scrolling. And after once halted, it does not scroll again. (broken)

And registering CADisplayLink in other thread/runloop (as described in answer of this question: CADisplayLink stops updating when UIScrollView scrolled) reduces UIScrollView behavior breaking, but cannot eliminate.


Solution

  • Use UITrackingRunLoopMode. It's specifically designed for scrolling stuffs.

    Otherwise, call render & present code at -scrollViewDidScroll too, not only in CADisplayLink's tick callback.