Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Swift.org 9 min read Case study mediumAdept

Swift at Apple: Migrating the TrueType Hinting Interpreter

Apple rewrote the TrueType font hinting bytecode interpreter from C to memory-safe Swift for its Fall 2025 OS releases. The new version renders pixel-identically and runs 13% faster on average. Correctness was checked with a unit suite at 99.7% coverage on both implementations and a fuzzer-minimized corpus of 4,200 PDFs containing 27 million glyphs, compared bitmap-for-bitmap against the C reference. Performance came from four changes: ~Copyable value types and Span to avoid ARC and exclusivity overhead, zero-copy projection types over the C structs instead of bridging copies that had cost ~20% of runtime, continuation-passing APIs to drop short-lived allocations, and inlining so generics get specialized. Only a few documented unsafe statements remain at the interop boundary, and the source has been published as a reference implementation.

Related posts

  • Optimizing WebKit & Safari for Speedometer 3.0

    WebKit hardMaster

    WebKit's Speedometer 3.0 work spans JavaScriptCore, DOM, style, layout, rendering and Safari itself, with measured gains for each change. The largest wins came from letting the simple text path handle font-variant-caps (4.5x on Editor-TipTap, ~7% overall) and from scheduling incremental sweeping and garbage collection opportunistically between rendering updates (6.5% on Speedometer 3.0). Other changes include reworked megamorphic and call inline caches, retuned inlining heuristics, lazy JIT code destruction, enum-based RenderObject type checks, cached CSS custom property resolution, and a larger IOSurface cache (hit rate ~30% to ~80%). Profile-guided optimization interacts with code changes in a surprising way: some improvements only appear, or briefly regress, until the PGO profiles refresh.

  • GSoC 2026 Showcase

    Swift.org easyNovice

    Swift's three Google Summer of Code 2026 projects all shipped. SourceKit-LSP now understands DocC, adding go-to-definition for symbol links, clickable preview links and Markdown highlighting in any LSP editor. The concurrency runtime gained an always-on task registry, sharded into 64 lists to avoid false sharing, that lldb and swift-inspect can query. In a 600,000-task stress test it added about 0.015s to a 0.37s run. swift-syntax's SwiftLexicalLookup module also gained qualified name lookup that resolves members through extensions and typealiases.

  • Swift 6.3 Released

    Swift.org mediumAdept

    Swift 6.3 adds a `@c` attribute for exposing Swift functions and enums to C (or implementing C-declared functions in Swift via `@c @implementation`), `Module::name` selectors for disambiguating APIs from different imported modules, and library performance attributes `@specialize`, `@inline(always)` and `@export(implementation)`. SwiftPM gains a preview of the unified Swift Build engine, prebuilt swift-syntax for macro libraries and a `show-traits` command. Swift Testing adds warning-severity issues, test cancellation and image attachments, and DocC gains experimental Markdown output, static HTML content and code block annotations. The release also ships the first official Swift SDK for Android and further Embedded Swift improvements.

  • Bringing Goodnotes to the web with Swift and WebAssembly

    Swift.org mediumAdept

    Goodnotes runs the same Swift code behind its iPad app in browsers by compiling it to WebAssembly with SwiftWasm, sharing 1.47M lines (66% of the 2.2M-line web codebase) including a rendering engine that targets Metal on iOS and WebGL on the web. The port required replacing libdispatch with Swift Concurrency, fixing code that assumed a 64-bit Int on wasm32, and abstracting I/O through dependency injection. WASI threads with Web Workers and SharedArrayBuffer, plus custom actor executors (SE-0392) that pin actors to specific workers, more than doubled INP but require cross-origin isolation. The roughly 50 MB binary (12 MB with Brotli) is cached with Service Workers, and Chrome DevTools debugging and a custom wasm-memprof heap profiler make the tooling workable. The WebAssembly support is upstreamed as of Swift 6.2.

  • Challenges of mixed SwiftUI and UIKit codebases in iOS Apps

    Medium Engineering mediumAdept

    Mixing SwiftUI into Medium's 2013-era UIKit iOS app brings recurring friction: sizing SwiftUI views hosted in UIHostingController as table/collection cells, mismatched scroll APIs (offset sign differs), and duplicated components like PostPreview implemented in both frameworks. Medium keeps UIKit for app-wide navigation and SwiftUI for local feature navigation, avoids SwiftUI TextField due to focus limitations, and notes weaker SwiftUI view debugging. A scroll performance issue from wrapping UILabel with NSAttributedString in a SwiftUI list was fixed by switching to native Text with AttributedString; raising the minimum target from iOS 13 to 16 reduced version-specific code.

The quest for software engineering knowledge.

Look:
Layout: