Open-Sourcing LayoutKit

Nick Snyder
4 min readintermediate
--
View Original

Overview

The article discusses the open-sourcing of LayoutKit, a fast view layout library for iOS applications developed by LinkedIn. It highlights the performance issues with Auto Layout and presents LayoutKit as a superior alternative that offers speed, asynchronous processing, and a declarative approach to layout management.

What You'll Learn

1

How to implement LayoutKit in your iOS applications

2

Why LayoutKit is faster than Auto Layout

3

When to use asynchronous layout calculations

Prerequisites & Requirements

  • Basic understanding of iOS layout systems
  • Familiarity with Swift programming language

Key Questions Answered

What performance issues did LinkedIn face with Auto Layout?
LinkedIn's performance profiling revealed that the main thread spent significant time running Auto Layout, causing noticeable delays when viewing profiles. This led to the need for a more efficient layout solution.
What are the key benefits of using LayoutKit over Auto Layout?
LayoutKit offers several advantages including speed comparable to manual layout, asynchronous layout calculations, a declarative approach for easier maintenance, and cacheable layout results. This results in improved performance and user experience.
How does LayoutKit improve performance for LinkedIn's iOS apps?
LayoutKit is reported to be eight times faster than Auto Layout and provides performance comparable to manual layout code. This was evidenced by significant performance gains in the LinkedIn and LinkedIn Job Search apps after switching to LayoutKit.

Key Statistics & Figures

Performance improvement
LayoutKit is eight times faster than Auto Layout
This was benchmarked on an iPhone 6 running iOS 9.3.2 with a 20 cell UICollectionView.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Frontend
Layoutkit
A declarative view layout library for iOS applications.
Programming Language
Swift
Used extensively for implementing LayoutKit in iOS applications.

Key Actionable Insights

1
Consider transitioning to LayoutKit for your iOS projects if you are facing performance issues with Auto Layout.
LayoutKit has shown to enhance layout speed and responsiveness, making it a viable option for applications that require smooth user interactions.
2
Utilize asynchronous layout calculations to prevent UI blocking during layout rendering.
This approach allows for a more fluid user experience, particularly in applications with complex layouts or data-heavy views.
3
Leverage the declarative nature of LayoutKit to simplify your layout code.
By using immutable data structures, LayoutKit makes it easier to develop, debug, and maintain layout code, which is beneficial for long-term project sustainability.

Common Pitfalls

1
Relying solely on Auto Layout can lead to performance bottlenecks in complex applications.
This happens because Auto Layout may not efficiently handle certain layout scenarios, causing delays and a poor user experience. Transitioning to a more performant solution like LayoutKit can mitigate these issues.

Related Concepts

Performance Optimization In Mobile Apps
Declarative UI Frameworks
Asynchronous Programming In Swift