Iglistkit: Performance Issues when using largeTitles on the NavigationBar in iOS 11

Created on 17 Dec 2017  路  13Comments  路  Source: Instagram/IGListKit

New issue checklist

General information

  • IGListKit version: Current
  • iOS version(s): 11.2
  • Xcode version: 9.2
  • Devices/Simulators affected: iPhone 6S

Debug information

-

When using the LargeTitle Navigationbar of iOS 11 together with a IGList with about 1300 Sections Controllers the transition between the normal Navbar Title and the large one is really laggy. As far as my research goes this is caused by the resize of the collection view and the therefore occurring usage of func sectionController(forSection section: Int) -> ListSectionController? to get all Sectionscontrollers.

How can I prevent this while the collection is resized?

question

All 13 comments

@Narsail that method is O(1) for lookup, so you could have 1,000,000 section controls and it鈥檒l take the same time to look them up.

How did you land on this conclusion? Have you performed a time profile?

Sent with GitHawk

@rnystrom

When working through your Examples I have the feeling my overall scrolling performances could be improved. But nonetheless I forked the repo and added large titles to the project (https://github.com/Narsail/IGListKit). Can you please open the "self-sizing cells" demo and try it out. At least there I can see the same performance issue while the navbar changes.

Time Profile Results:

There is a huge difference of work on the Main Thread dependent on the number of Section Controllers. The only action I did was to scroll up and down to see the "LargeTitle" Navigationbar Effect. So there wasn't much of a change for the visible controllers.

With 10 Section Controllers:
screen shot 2017-12-18 at 13 10 30

With >1300 Section Controllers:
screen shot 2017-12-18 at 13 12 04

Hmm, looks like we need some symbols to see where the perf issue is coming from there. Also I鈥檓 a little suspect for self sizing cell stuff, they are notoriously buggy.

I鈥檒l take a look at your fork and see if something stands out!

Sent with GitHawk

@rnystrom If you want you can directly compile my app and test it there. I don't use self sizing cells.

https://github.com/Narsail/CryptoMarket

@rnystrom Can you give me a time frame when you will look into this problem? I would like to ship my app with the new iOS Navbar soon :)

So I changed my implementation to let one SectionController contain the 1300 Items instead of having 1300 SectionControllers with one item (facepalm) but the question remains why a high number of sectioncontrollers is influencing the transition of the navbar so much. CollectionKit has a similar problem due to recalculating the cell size for every cell (even the invisible ones) when the CollectionView changes its size. The issue of the IGListKit might be similar?

I haven鈥檛 had any time to look into the issue. It鈥檚 very likely a layout error, possibly invalidating layout with every bounds change. In Instagram we have thousands of section controllers in grids (each with just a single cell) and maintain solid 60fps. That鈥檚 actually the recommended architecture. Having a single section defeats one of the major architecture advantages of using IGListKit.

Did you get a chance to use Time Profiler with symbolication? That鈥檇 be much easier for me to debug. I usually don鈥檛 have time to debug other apps 馃槃

Sent with GitHawk

Oh okay, so I did it the right way. Mmh. Do you have a quick tutorial on how to debug with symbolication? That is something I haven't used before.

This SO question should have all the info you need to make sure that a profile build gets symbolicated.

@rnystrom Thanks for that Thread. This was helping quickly. So in the following screenshot I basically scrolled once upwards until the LargeNavbar was transitioned into the top bar and then back to its starting position (being a Large Nav Title) again. That produced two CPU spikes and the shown time profile. Does this help?^
screen shot 2018-01-15 at 20 44 21 2

@Narsail I'm using 3.4.0. I'm using the large titles in my navigation bar, but on scrolling though, the large title doesn't transition to smaller title in the standard navigation bar. Any idea what I might be missing?

It's not IGListKit issue; you can easily reproduce it with default UICollectionView, 5000 items in it and Large Navbar turned on.
I don't know if i missed something, but for me it seems like a bug in UICollectionView. It recalculates sizes and reconfigures 30-50 cells at once on each position change during scrolling with NavBar transition.

Closing as it seems like an issue w/ UICollectionView

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rnystrom picture rnystrom  路  3Comments

lucabartoletti picture lucabartoletti  路  3Comments

rnystrom picture rnystrom  路  3Comments

kleiberjp picture kleiberjp  路  3Comments

jessesquires picture jessesquires  路  3Comments