Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Upgrading the Networking Stack of LINE iOS

Upgrading the Networking Stack of LINE iOS

Eebedc2ee7ff95ffb9d9102c6d4a065c?s=128

LINE DevDay 2020

November 26, 2020
Tweet

Transcript

  1. None
  2. Background › Refactoring in a large project › LINT (LINE

    Improvement for Next Ten years) from last year https://linedevday.linecorp.com/jp/2019/sessions/A1-2 › Push optimization not covered
  3. Agenda › Reason for Upgrading › Upgrade Process › Lessons

    Learned
  4. As Is Deprecated / Customized SPDY Objective- C / C

    Widely Adopted
  5. To Be HTTP3 HTTP2 Swift Smooth Transition

  6. Process Create an Abstraction Layer Legacy Networking Features

  7. Process Create an Abstraction Layer Legacy Networking Features

  8. Process Create an Abstraction Layer Legacy Networking Features Abstraction Layer

  9. Process Create an Abstraction Layer Legacy Networking Features Abstraction Layer

  10. Abstraction Layer Collecting Request Information Request › Host › Path

    › Method › Headers › Data Serialization
  11. Abstraction Layer Plugin Request Will Send Request Response Networking Abstraction

    Layer Abstraction Layer Networking Layer Did Receive Response
  12. Abstraction Layer Plugin Request Turn On Network Activity Indicator Response

    Networking Abstraction Layer Abstraction Layer Networking Layer Turn Off Network Activity Indicator
  13. Abstraction Layer Plugin Request Log Request Response Networking Abstraction Layer

    Abstraction Layer Networking Layer Log Response
  14. Abstraction Layer Plugin Request Response Networking Abstraction Layer Abstraction Layer

    Networking Layer Check for a special header Modify headers
  15. Abstraction Layer Plugin › Business logic separated from actual networking

    implementation › Business logic packed in a modularized way (in a single plugin)
  16. Feature Feature Abstraction Layer Migration Abstraction Layer Legacy Networking Feature

    Feature Feature Feature
  17. Abstraction Layer Migration › 70+ Tasks › 500+ Calls ›

    Progressively
  18. HTTP2 Implementation Legacy Networking Features Abstraction Layer Switcher HTTP2 Networking

  19. HTTP2 Implementation SwiftNIOHTTP2 Simple wrapper over URLSession

  20. Switching to HTTP2 HTTP2 Networking Features Abstraction Layer Switcher Legacy

    Networking
  21. Switching to HTTP2 HTTP2 Networking Features Abstraction Layer Switcher Legacy

    Networking
  22. Switching to HTTP2 HTTP2 Networking Features Abstraction Layer Switcher Legacy

    Networking Server-Controlled Flag
  23. Switching to HTTP2 HTTP2 Networking Features Abstraction Layer Switcher Legacy

    Networking Server-Controlled Flag
  24. Switching to HTTP2 HTTP2 Networking Features Abstraction Layer Switcher Legacy

    Networking Server-Controlled Flag
  25. Switching to HTTP2 Phases Progressive roll out QA Real Dev

  26. Lessons Learned › Have a clear separation of different abstraction

    levels › Use an abstraction layer to isolate the legacy code and upgrade to new code
  27. References › https://davedelong.com/blog/2020/06/27/http-in-swift-part-1/ › https://github.com/Moya/Moya › https://github.com/apple?q=swift-nio

  28. Thank you