ios - UICollectionView with Custom Layout Going Blank -


i have built tv guide style application utilizes uicollectionview custom uicollectionviewlayout. custom layout uses 4 different custom uicollectionviewcells. have run interesting problem has stumped me , team. post quite long, done way give full context. if have time read , toss me ideas. appreciate it. always, community help.

tl;dr - uicollectionview custom layout (subclass of uicollectionviewlayout) randomly loses data in view. goes blank. .reloaddata() called on viewdidappear , not fix. stumped cause.

section 0, item 0 1 type of cell , kept in top left @ times. scroll, cell moved , kept in top left corner.

section 0, item 1-n second type of cell , kept @ top @ times.

section 1-n, item 0-n "stations", type of cell, , kept along left border @ times.

all other cells "shows" , fourth type of cell , mapped specific x,y coordinate based on time , station.

this collectionview performant , has allowed give great user experience part. however, when loaded 10 days worth of data. uses decent amount of memory. ~100-150mb depending on lineup, number of stations, , length of shows. shorter shows means more cells mapped out collection view.

when app running large chunk of guide data, sometimes, collectionview hiccup , floating headers stop moving. all of cells disappear. have affectionately started calling white screen of death entire collection rendered empty. @ time, scroll bars still visible , can see scrolling around, no cells loaded.

we've created problem few times device connected xcode's debugger , have data. data populating cells still available debugger. cellforitematindexpath can called debugger , returns uicollectionviewcell. numberofsections , numberofitemsinsections still functions , shows correct numbers when printing debugger. cellforitematindexpath function never called after collection goes empty. breakpoint in method never hit. layout still accessible , variables can accessed no problems.

now things seem abnormal, don't know with.

collectionview.contentsize , collectionview.collectionviewlayout.contentsize different. on non-broke device, same when looking through debugger.

collectionview.visiblecells returns empty array. technically correct our collection in white screen of death mode... have sections , items in sections, not sure that.

the problem intermittent, can reproduce few times hour if trying hard enough. think it's memory related, because never happens on simulator. on physical devices.

since unreleased app client, i've blacked out navigational controls. example of empty collection view

has seen similar problem? have ideas try next?

last note, thank reading far! :)

seeing upvoted question, thought come , post resolution landed on.

our collectionview calling singleton managing large amount of data application. singleton being populated in background users scrolled keep data in view. these background updates singleton being managed via background threads running in low priority. built threads update data stores first, update accessor methods know new data. our attempt @ thread safety, accessors wouldn't know there other data existed until after data done being modified. however, did not work. more details below.

after testing extensively multiple devices, realized our problem showed in high volume on days, took data , started analyzing collectionview cells given dates, came find out days when problem showed regularly, there cells being generated had large sizes, example, single cell in row might span width of 4-5 iphones. after searching, found common problem people had , downsized cells. our cells linked times , lengths.

more research put forth , took swing @ removing threading. meant when our user hit end of collection, push modal view showed activity indicator , blocked user input while singleton updated. immediately resolved our problem.

the notes our research:

  • extremely large cells, width or height, cause problems collectionviews , caution should taken.
  • these large cells can make problems occur in higher frequency normal, however, did not appear the cause of our issue.
  • thread safety our issue, @ point collectionview losing it's connection data source , not recover. tried several remedies relink data source, none worked. fix remove threading.

hope helps!


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -