axiom-swiftui-performance

0
0
Source

Use when UI is slow, scrolling lags, animations stutter, or when asking 'why is my SwiftUI view slow', 'how do I optimize List performance', 'my app drops frames', 'view body is called too often', 'List is laggy' - SwiftUI performance optimization with Instruments 26 and WWDC 2025 patterns

Install

mkdir -p .claude/skills/axiom-swiftui-performance && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5779" && unzip -o skill.zip -d .claude/skills/axiom-swiftui-performance && rm skill.zip

Installs to .claude/skills/axiom-swiftui-performance

About this skill

SwiftUI Performance Optimization

When to Use This Skill

Use when:

  • App feels less responsive (hitches, hangs, delayed scrolling)
  • Animations pause or jump during execution
  • Scrolling performance is poor
  • Profiling reveals SwiftUI is the bottleneck
  • View bodies are taking too long to run
  • Views are updating more frequently than necessary
  • Need to understand cause-and-effect of SwiftUI updates

Example Prompts

These are real questions developers ask that this skill is designed to answer:

1. "My app has janky scrolling and animations are stuttering. How do I figure out if SwiftUI is the cause?"

→ The skill shows how to use the new SwiftUI Instrument in Instruments 26 to identify if SwiftUI is the bottleneck vs other layers

2. "I'm using the new SwiftUI Instrument and I see orange/red bars showing long updates. How do I know what's causing them?"

→ The skill covers the Cause & Effect Graph patterns that show data flow through your app and which state changes trigger expensive updates

3. "Some views are updating way too often even though their data hasn't changed. How do I find which views are the problem?"

→ The skill demonstrates unnecessary update detection and Identity troubleshooting with the visual timeline

4. "I have large data structures and complex view hierarchies. How do I optimize them for SwiftUI performance?"

→ The skill covers performance patterns: breaking down view hierarchies, minimizing body complexity, and using the @Sendable optimization checklist

5. "We have a performance deadline and I need to understand what's slow in SwiftUI. What are the critical metrics?"

→ The skill provides the decision tree for prioritizing optimizations and understands pressure scenarios with professional guidance for trade-offs


Overview

Core Principle: Ensure your view bodies update quickly and only when needed to achieve great SwiftUI performance.

NEW in WWDC 2025: Next-generation SwiftUI instrument in Instruments 26 provides comprehensive performance analysis with:

  • Visual timeline of long updates (color-coded orange/red by severity)
  • Cause & Effect Graph showing data flow through your app
  • Integration with Time Profiler for CPU analysis
  • Hangs and Hitches tracking

Key Performance Problems:

  1. Long View Body Updates — View bodies taking too long to run
  2. Unnecessary View Updates — Views updating when data hasn't actually changed

iOS 26 Framework Performance Improvements

"Performance improvements to the framework benefit apps across all of Apple's platforms, from our app to yours." — WWDC 2025-256

SwiftUI in iOS 26 includes major performance wins that benefit all apps automatically. These improvements work alongside the new profiling tools to make SwiftUI faster out of the box.

List Performance (macOS Focus)

Massive gains for large lists

  • 6x faster loading for lists of 100,000+ items on macOS
  • 16x faster updates for large lists
  • Even bigger gains for larger lists
  • Improvements benefit all platforms (iOS, iPadOS, watchOS, not just macOS)
List(trips) { trip in // 100k+ items
    TripRow(trip: trip)
}
// iOS 26: Loads 6x faster, updates 16x faster on macOS
// All platforms benefit from performance improvements

Impact on your app

  • Large datasets (10k+ items) see noticeable improvements
  • Filtering and sorting operations complete faster
  • Real-time updates to lists are more responsive
  • Benefits apps like file browsers, contact lists, data tables

Scrolling Performance

Reduced dropped frames during high-speed scrolling

SwiftUI has improved scheduling of user interface updates on iOS and macOS. This improves responsiveness and lets SwiftUI do even more work to prepare for upcoming frames. All in all, it reduces the chance of your app dropping a frame while scrolling quickly at high frame rates.

Key improvements

  1. Better frame scheduling — SwiftUI gets more time to prepare for upcoming frames
  2. Improved responsiveness — UI updates scheduled more efficiently
  3. Fewer dropped frames — Especially during quick scrolling at 120Hz (ProMotion)

When you'll notice

  • Scrolling through image-heavy content
  • High frame rate devices (iPhone Pro, iPad Pro with ProMotion)
  • Complex list rows with multiple views

Nested ScrollViews with Lazy Stacks

Photo carousels and multi-axis scrolling now properly optimize

ScrollView(.horizontal) {
    LazyHStack {
        ForEach(photoSets) { photoSet in
            ScrollView(.vertical) {
                LazyVStack {
                    ForEach(photoSet.photos) { photo in
                        PhotoView(photo: photo)
                    }
                }
            }
        }
    }
}
// iOS 26: Nested scrollviews now properly delay loading with lazy stacks
// Great for photo carousels, Netflix-style layouts, multi-axis content

Before iOS 26 Nested ScrollViews didn't properly delay loading lazy stack content, causing all nested content to load immediately.

After iOS 26 Lazy stacks inside nested ScrollViews now delay loading until content is about to appear, matching the behavior of single-level ScrollViews.

Use cases

  • Photo galleries with horizontal/vertical scrolling
  • Netflix-style category rows
  • Multi-dimensional data browsers
  • Image carousels with vertical detail scrolling

SwiftUI Performance Instrument Enhancements

New lanes in Instruments 26

The SwiftUI instrument now includes dedicated lanes for:

  1. Long View Body Updates — Identify expensive body computations
  2. Platform View Updates — Track UIKit/AppKit bridging performance (Long Representable Updates)
  3. Other Long Updates — All other types of long SwiftUI work

These lanes are covered in detail in the next section.

Performance Improvement Summary

Automatic wins (recompile only)

  • ✅ 6x faster list loading (100k+ items, macOS)
  • ✅ 16x faster list updates (macOS)
  • ✅ Reduced dropped frames during scrolling
  • ✅ Improved frame scheduling on iOS/macOS
  • ✅ Nested ScrollView lazy loading optimization

No code changes required — rebuild with iOS 26 SDK to get these improvements.

Cross-reference SwiftUI 26 Features (swiftui-26-ref skill) — Comprehensive guide to all iOS 26 SwiftUI changes


The SwiftUI Instrument (Instruments 26)

Getting Started

Requirements:

  • Install Xcode 26
  • Update devices to latest OS releases (support for recording SwiftUI traces)
  • Build app in Release mode for accurate profiling

Launch:

  1. Open project in Xcode
  2. Press Command-I to profile
  3. Choose SwiftUI template from template chooser
  4. Click Record button

Template Contents

The SwiftUI template includes three instruments:

  1. SwiftUI Instrument (NEW) — Identifies performance issues in SwiftUI code
  2. Time Profiler — Shows CPU work samples over time
  3. Hangs and Hitches — Tracks app responsiveness

SwiftUI Instrument Track Lanes

Lane 1: Update Groups

  • Shows when SwiftUI is actively doing work
  • Empty during CPU spikes? → Problem likely outside SwiftUI

Lane 2: Long View Body Updates

  • Highlights when body property takes too long
  • Most common performance issue — start here

Lane 3: Long Representable Updates

  • Identifies slow UIViewRepresentable/NSViewRepresentable updates
  • UIKit/AppKit integration performance

Lane 4: Other Long Updates

  • All other types of long SwiftUI work

Color-Coding System

Updates shown in orange and red based on likelihood to cause hitches:

  • Red — Very likely to contribute to hitch/hang (investigate first)
  • Orange — Moderately likely to cause issues
  • Gray — Normal updates, not concerning

Note: Whether updates actually result in hitches depends on device conditions, but red updates are the highest priority.


Understanding the Render Loop

Normal Frame Rendering

Frame 1:
├─ Handle events (touches, key presses)
├─ Update UI (run view bodies)
│  └─ Complete before frame deadline ✅
├─ Hand off to system
└─ System renders → Visible on screen

Frame 2:
├─ Handle events
├─ Update UI
│  └─ Complete before frame deadline ✅
├─ Hand off to system
└─ System renders → Visible on screen

Result: Smooth, fluid animations

Frame with Hitch (Long View Body)

Frame 1:
├─ Handle events
├─ Update UI
│  └─ ONE VIEW BODY TOO SLOW
│  └─ Runs past frame deadline ❌
├─ Miss deadline
└─ Previous frame stays visible (HITCH)

Frame 2: (Delayed)
├─ Handle events (delayed by 1 frame)
├─ Update UI
├─ Hand off to system
└─ System renders → Finally visible

Result: Previous frame visible for 2+ frames = animation stutter

Frame with Hitch (Too Many Updates)

Frame 1:
├─ Handle events
├─ Update UI
│  ├─ Update 1 (fast)
│  ├─ Update 2 (fast)
│  ├─ Update 3 (fast)
│  ├─ ... (100 more fast updates)
│  └─ Total time exceeds deadline ❌
├─ Miss deadline
└─ Previous frame stays visible (HITCH)

Result: Many small updates add up to miss deadline

Key Insight: View body runtime matters because missing frame deadlines causes hitches, making animations less fluid.

Reference:


Problem 1: Long View Body Updates

Identifying Long Updates

  1. Record trace in Instruments with SwiftUI template
  2. Look at Long View Body Updates lane — any orange/red bars?
  3. Expand SwiftUI track to see subtracks
  4. Select View Body Updates subtrack
  5. Filter to long updates:
    • Detail pane → Dropdown → Choose "Long View Body Updates summary"

Analyzing with Time Profiler

Workflow:

  1. Find long update in Long View Body Updates summary
  2. Hover over view name → Click arrow → "Show Updates"
  3. Right-click on long update → "Set Inspection Range and Zoom" 4

Content truncated.

axiom-ios-build

CharlesWiltgen

Use when ANY iOS build fails, test crashes, Xcode misbehaves, or environment issue occurs before debugging code. Covers build failures, compilation errors, dependency conflicts, simulator problems, environment-first diagnostics.

91

axiom-getting-started

CharlesWiltgen

Use when first installing Axiom, unsure which skill to use, want an overview of available skills, or need help finding the right skill for your situation — interactive onboarding that recommends skills based on your project and current focus

00

axiom-ui-testing

CharlesWiltgen

Use when writing UI tests, recording interactions, tests have race conditions, timing dependencies, inconsistent pass/fail behavior, or XCTest UI tests are flaky - covers Recording UI Automation (WWDC 2025), condition-based waiting, network conditioning, multi-factor testing, crash debugging, and accessibility-first testing patterns

00

axiom-core-spotlight-ref

CharlesWiltgen

Use when indexing app content for Spotlight search, using NSUserActivity for prediction/handoff, or choosing between CSSearchableItem and IndexedEntity - covers Core Spotlight framework and NSUserActivity integration for iOS 9+

00

axiom-vision-diag

CharlesWiltgen

subject not detected, hand pose missing landmarks, low confidence observations, Vision performance, coordinate conversion, VisionKit errors, observation nil, text not recognized, barcode not detected, DataScannerViewController not working, document scan issues

00

axiom-now-playing-carplay

CharlesWiltgen

CarPlay Now Playing integration patterns. Use when implementing CarPlay audio controls, CPNowPlayingTemplate customization, or debugging CarPlay-specific issues.

00

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

643969

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

591705

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

318399

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

340397

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

452339

fastapi-templates

wshobson

Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.

304231

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.