How WhatsApp Made Key Transparency Work (And Why It Matters)

Image
How WhatsApp's Key Transparency Changed the Game for Encrypted Messaging Okay so let's talk about something actually important for once - how WhatsApp made their encryption more trustworthy without making us jump through hoops. You know how every messaging app claims to be "secure" these days? Well WhatsApp actually put their money where their mouth is with this Key Transparency thing. Let me explain why this matters more than you might think. Visual from their tech docs - looks complicated but trust me it's cool The Big Problem Nobody Talks About So we all know WhatsApp uses end-to-end encryption. Great. But here's the sketchy part nobody mentions - how do you REALLY know you're talking to who you think you are? Like, what if: Some hacker swapped the encryption keys without you knowing? There's a middleman reading your messages right now? The app itself got compromised somehow? Scary stuff right? That's where Key Trans...

Advertisement

Migrating Airbnb’s iOS Build System from Buck to Bazel: A Technical Journey




Introduction: Why Migrate at All?

Imagine trying to assemble a massive jigsaw puzzle, only to realize halfway through that the pieces don’t fit together as smoothly as you’d hoped. This was the challenge Airbnb faced with its iOS build system, which relied on Buck, a build tool that had served them well but was becoming increasingly difficult to scale and maintain. Enter Bazel, a powerful and extensible build system that promised better performance, scalability, and developer productivity.

In this blog post, we’ll dive into Airbnb’s journey of migrating their iOS build system from Buck to Bazel. We’ll explore the technical challenges they faced, the solutions they implemented, and the lessons they learned along the way. Whether you’re an iOS developer, a build engineer, or a tech enthusiast, this deep dive will provide valuable insights into modern build systems and migration strategies.

Why Migrate from Buck to Bazel?

Airbnb’s iOS codebase had grown significantly over the years, and with that growth came new challenges:

  • Scalability Issues: Buck struggled to handle the increasing complexity and size of the codebase.
  • Performance Bottlenecks: Build times were becoming longer, impacting developer productivity.
  • Limited Ecosystem: Buck’s ecosystem lacked some of the features and integrations that Bazel offered.
  • Community Support: Bazel had a larger and more active community, making it easier to find solutions and best practices.

Bazel, developed by Google, offered several advantages:

  • Hermetic Builds: Ensures reproducibility by isolating builds from the environment.
  • Incremental Builds: Reduces build times by only rebuilding what has changed.
  • Extensibility: Supports custom rules and integrations for unique use cases.
  • Cross-Platform Support: Works seamlessly across iOS, Android, and other platforms.

The Migration Process

1. Assessing the Existing Build System

Before diving into the migration, Airbnb’s engineering team conducted a thorough assessment of their existing Buck-based build system. This included:

  • Identifying Dependencies: Mapping out all dependencies and their relationships.
  • Analyzing Build Times: Pinpointing bottlenecks and areas for optimization.
  • Evaluating Bazel’s Compatibility: Ensuring Bazel could handle Airbnb’s specific requirements.

2. Building a Proof of Concept

To validate Bazel’s potential, the team created a proof of concept (PoC) for a small part of the codebase. The PoC demonstrated that Bazel could:

  • Reduce build times by up to 40% for incremental builds.
  • Handle complex dependency graphs more efficiently.
  • Integrate with existing tools and workflows.

3. Gradual Migration

Instead of migrating the entire codebase at once, Airbnb adopted a phased approach:

  • Module-by-Module Migration: Migrating individual modules to Bazel while keeping the rest of the codebase on Buck.
  • Hybrid Build System: Using a custom wrapper to allow Buck and Bazel to coexist during the transition.
  • Automated Testing: Ensuring that every migrated module passed all tests before moving to the next.

Technical Challenges and Solutions

Challenge 1: Dependency Management

Airbnb’s codebase had a complex web of dependencies, and migrating them to Bazel required careful planning.

Solution:

  • The team used Bazel’s WORKSPACE and BUILD files to define dependencies explicitly.
  • They created custom Bazel rules to handle internal dependencies and third-party libraries.
# WORKSPACE file
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "some_dependency",
    url = "https://example.com/some_dependency.zip",
    sha256 = "abc123...",
)

# BUILD file
objc_library(
    name = "my_library",
    srcs = ["MyClass.m"],
    hdrs = ["MyClass.h"],
    deps = ["@some_dependency//:library"],
)

Challenge 2: Build Performance

While Bazel offered faster incremental builds, the initial full builds were slower due to the overhead of setting up the build graph.

Solution:

  • The team optimized Bazel’s build graph by reducing unnecessary dependencies.
  • They leveraged Bazel’s remote caching to share build artifacts across the team.

Challenge 3: Developer Experience

Migrating to a new build system can disrupt developer workflows.

Solution:

  • Airbnb provided extensive documentation and training to help developers adapt to Bazel.
  • They built custom tools to automate common tasks and integrate Bazel with existing workflows.

Lessons Learned

  1. Start Small: Begin with a PoC to validate the technology and build team confidence.
  2. Plan Thoroughly: Map out dependencies and potential challenges before starting the migration.
  3. Adopt Incrementally: A phased approach minimizes risks and allows for continuous learning.
  4. Invest in Tooling: Custom tools and automation can significantly improve developer productivity.
  5. Communicate Clearly: Keep the team informed and involved throughout the migration process.

The Future of Bazel at Airbnb

Airbnb’s migration to Bazel is still ongoing, but the results so far are promising. The team plans to:

  • Complete the migration of the entire iOS codebase to Bazel.
  • Explore Bazel’s capabilities for other platforms, such as Android and backend services.
  • Contribute to the Bazel community by open-sourcing custom rules and tools.

By embracing Bazel, Airbnb is not only improving its build system but also setting a benchmark for modern build automation. You can read more details here: Migrating Our iOS Build System from Buck to Bazel.

Advertisement