Slide 1

Slide 1 text

AsyncLayoutInflater vs Litho Keishin Yokomaku / potatotips #41 @ Yahoo Japan, Inc.

Slide 2

Slide 2 text

AsyncLayoutInflater vs Litho About Me ▸ Keishin Yokomaku ▸ Drivemode, Inc. / Principal Engineer ▸ KeithYokoma: GitHub / Twitter / Qiita / Tumblr / Stack Overflow ▸ Books: Android Academia / Grimoire of Android / Nanairo Android ▸ Fun: Gymnastics / Cycling / Photography / Motorsport / Hiking ▸ Today’s Quote: “෋࢜ࢁΛࣗసंͰొΔ૘շײ” 2

Slide 3

Slide 3 text

AsyncLayoutInflater vs Litho 3

Slide 4

Slide 4 text

AsyncLayoutInflater vs Litho Overview of AsyncLayoutInflater ▸ Member of support v4 library. ▸ Inflate xml layout in a background thread. ▸ To avoid blocking UI thread so that UI keeps being responsive. ▸ Inflated layout is not added to parent. ▸ For more details: https://goo.gl/prNKrl. 4

Slide 5

Slide 5 text

AsyncLayoutInflater vs Litho Overview of Litho ▸ Declarative UI implementation framework. ▸ Supports asynchronous measure and layout. ▸ Measure and layout operations run on a background thread. ▸ Draw operation runs on UI thread. ▸ For more details: https://goo.gl/Djkys0. 5

Slide 6

Slide 6 text

AsyncLayoutInflater vs Litho How fast could they inflate the layout? ▸ Condition. ▸ Put 10,000 TextViews in one ViewGroup and inflate it. ▸ Tested with Nexus5X running Nougat 7.1.2. ▸ Code. ▸ GitHub: https://goo.gl/xGq9XT. ▸ Very rough implementation. 6

Slide 7

Slide 7 text

AsyncLayoutInflater vs Litho Layout to inflate with AsyncLayoutInflater 7

Slide 8

Slide 8 text

AsyncLayoutInflater vs Litho Layout to inflate with Litho 8

Slide 9

Slide 9 text

Result… 9

Slide 10

Slide 10 text

AsyncLayoutInflater vs Litho At first: No Contest ▸ No chance to win for Litho because it is too slow to compose a huge layout. ▸ As ProAndroidDev mentioned, Litho is not a full replacement for XML. ▸ Problem in the implementation ▸ No scrollable container for 10,000 texts so that
 Litho will squeeze them in bounds of screen size. 10

Slide 11

Slide 11 text

AsyncLayoutInflater vs Litho Litho and scrollable container ▸ RecyclerViews ▸ Of course it’s scrollable. ▸ ScrollViews ▸ No equivalent component in Litho so far. ▸ Parent view of LithoView can be ScrollView 11

Slide 12

Slide 12 text

Again… 12

Slide 13

Slide 13 text

AsyncLayoutInflater vs Litho Result table 13 # AsyncLayoutInflater Litho 1 2,584,304,320 nano secs (2 secs) 19,826,206,923 nano secs (19 secs) 2 6,367,538,759 nano secs (6 secs) 21,579,648,348 nano secs (21 secs) 3 3,169,053,024 nano secs (3 secs) 22,534,724,276 nano secs (22 secs) 4 2,852,954,503 nano secs (2 secs) 22,701,877,992 nano secs (22 secs) 5 3,020,239,467 nano secs (3 secs) 21,354,948,117 nano secs (21 secs) 6 2,869,514,244 nano secs (2 secs) 21,115,173,145 nano secs (21 secs) 7 2,449,029,515 nano secs (2 secs) 21,619,548,768 nano secs (21 secs) 8 6,719,644,993 nano secs (6 secs) 19,353,791,876 nano secs (19 secs) 9 5,927,050,643 nano secs (5 secs) 20,020,680,380 nano secs (20 secs) 10 6,206,141,191 nano secs (6 secs) 20,739,572,795 nano secs (20 secs) Ave 4216547065.9 nano secs (4 secs) 21084617262 nano secs (21 secs)

Slide 14

Slide 14 text

AsyncLayoutInflater is faster than Litho 14

Slide 15

Slide 15 text

AsyncLayoutInflater vs Litho Keishin Yokomaku / potatotips #41 @ Yahoo Japan, Inc.

Slide 16

Slide 16 text

Drivemode We are hiring Android/iOS engineers! 16

Slide 17

Slide 17 text

Drivemode We are hiring Android/iOS engineers! 17