etsy / AndroidStaggeredGrid

An Android staggered grid view which supports multiple columns with rows of varying sizes.
https://github.com/etsy/AndroidStaggeredGrid
4.76k stars 1.13k forks source link

Inflating a layout containing StaggeredGridView causes "too much work on main thread" warnings #110

Closed nucleartide closed 10 years ago

nucleartide commented 10 years ago

I've timed the onCreateView() of a fragment containing a StaggeredGridView, and logcat displays the following:

05-31 19:38:03.818  27544-27544/com.nucleartide.test.app D/SomeFragment﹕ Fragment inflation: 0.500305176 seconds
05-31 19:38:03.828  27544-27544/com.nucleartide.test.app D/SomeFragment﹕  onCreateView(): 0.524261475 seconds
05-31 19:38:03.828  27544-27544/com.nucleartide.test.app I/Choreographer﹕ Skipped 42 frames!  The application may be doing too much work on its main thread.
05-31 19:38:04.648  27544-27544/com.nucleartide.test.app I/Choreographer﹕ Skipped 45 frames!  The application may be doing too much work on its main thread.

With StaggeredGridView removed, inflating the same fragment is noticeably snappier. Also, the "Choreographer" lines do not appear:

05-31 19:43:04.341  28584-28584/com.nucleartide.test.app D/SomeFragment﹕ Fragment inflation: 0.009277345 seconds
05-31 19:43:04.351  28584-28584/com.nucleartide.test.app D/SomeFragment﹕ onCreateView(): 0.027099609 seconds

Is there anything that can be done about this?

nucleartide commented 10 years ago

Hmm, this is probably an issue with my item layouts, not the StaggeredGrid. Closing...