Optimize app power and performance for spatial computing

Optimize app power and performance for spatial computing

The next step Apple suggest is to learn about the tools, learn to use optimize your application.

“Learn how you can create powerful apps and games for visionOS by optimizing for performance and efficiency. We’ll cover the unique power characteristics of the platform, explore building a performance plan, and share some of the tools and strategies to test and optimize your apps.” -Apple

Explore performance with spatial computing

  • Continuously updating content
    • Renders every frame at all times
    • Computes spatial algorithms continuously
    • Run multiple apps at the same time
      • Responsiveness
      • Immersion
      • Comfort
  • Measure performance metrics - For more details see Ultimate application performance survival guide
    • Power
      • Thermal Pressure
    • Hangs
      • Main Thread is stalled
    • Rendering
      • Essential for static content as well as active
    • Launch Time
    • Disk Writes
    • Memory
    • Terminations

Profile your app

  • Development and testing
    • XCTest Performance tests
    • Xcode Gauges
    • Instruments
    • Profile many scenarios
      • Profile on device
      • Use different user input methods
      • Play audio and video
      • Use FaceTime
      • Check sustained performance
      • Run multiple apps
  • Beta and Public release
    • MetricKit
      • Energy dionostics
  • Public Release
    • Xcode Organizer

Optimize your app

Explore render performance

  • Render pipeline

  • App needs the to recieve frame from rendering deadline, otherwise lag

Optimize SwiftUI and UIKit content for render performance

  • Rendering static UI costs
    • System renders static UI content
    • Translucency and overlap generate overdraw
  • Optimize static UI rendering
    • Minimize translucency and overlap with Z offset
    • Lower the default window sizes
  • Redrawing UI costs
  • Optimize UI redraws
    • Reduce offscreen render passes
      • Shadow, Blur, Masking reduced
    • Eliminate unnecessary UI view updates
      • Use @Observable with SwiftUI View
        • Provides more granular UI change tracking and reduce unneeded Updates

Optimize RealityKit content for render performance

  • Optimize 3D scene
  • Optimize mesh rendering
  • Optimize Render updates
    • Your app sends updates to render server
      • Common causes of expensive updates
        • Frequent entity creation and destruction
        • Complex animation
        • Frequent SwiftUI redraws
        • Loading too many assets
    • Optimize entity render updates
      • Create entities in advance and show them as needed
      • Flatten entity hierarchies
      • Minimize updates from code-based animations
      • Avoid excessive SwiftUI redraws from RealityKit entity updates
  • Optimize RealityKit asset loading
    • Use asynchronous-loading APIs
    • Load assets in advance
    • Reuse assets between entities
    • Export with Reality Composer Pro
    • Reduce asset size
  • Optimize fully immersive content
    • Reduce GPU work per pixel
    • Optimize for GPU power use
    • Use unlit “custom” materials in Reality Composer Pro

Optimize Metal apps for render performance

Learn about user input performance

  • Input Response Times
    • Eyes, Hands, Voice, Hardward
      • These are processed on the main thread
    • Input response time depends on display refresh rate
    • At 90 Hz, aim to keep updates below 8ms
  • Optimize interactive content
    • Use static colliders over dynamic colliders for RealityKit content
    • Minimize overlapping interactive content to reduce hit testing

Optimize ARKit usage

  • Always-on ARKit algorithms to anchor items
  • Optimize for anchoring work
    • Anchors contribute to computational needs
    • Consider if anchors need to be tracked continuously
      • Use TrackingMode.once on AnchorComponents
      • Minimize persised and transient anchor counts
  • Optimize ARKit data use
    • Query latest ARKit Data
    • Pose Prediction queries are not free
    • Toggle collision data generation for scene understanding meshes

Explore audio and video playback performance

  • Spatial Audio
    • Spatial Audio is used by default
    • Requires real-time computation work
  • Optimize Spatial Audio
    • Concurrent playback
    • Moving sources
    • Sound stage size
  • Video playback
    • Each video frame needs to be decoded and rendered
  • Optimize video
    • Minimize UI and 3D render updates
    • Use different video frame rates
    • Reduce concurrent playback
  • Video presentation methods

Bring great performance to SharePlay experiences

  • Sustain great performance over time
  • Optimize for long-running experiences
    • Start with great sustained performance offline
    • Profile rendering and input on both sides
    • Profile for power consumption
    • Turn off unneeded features during SharePlay

Avoid terminations from thermal and memory pressure

Notes mentioning this note


Here are all the notes in this garden, along with their links, visualized as a graph.

100DaysofSwiftUIAlgorithmsAffirmation TimerBPM ClapperBPM TrainingMetronome Vintage 3DHackingWithSwiftSwiftUI Accessibility Hiding and Grouping DataSwiftUI Accessibility Identifying ViewsSwiftUI Accessibility Read Value ControlsSwiftUI Accessibility Support as NeededSwiftUI AccessibilitySwiftUI Advanced ViewsSwiftUI CGAffineTransformSwiftUI Drawing animatableDataSwiftUI Drawing Special EffectsSwiftUI DrawingSwiftUI ImagePaintSwiftUI MetalSwiftUI PathsSwiftUI ShapesSwiftUI Image AlbumImage GeometryReaderSwiftUI Image InterpolationSwiftUI ImageSwiftUI Intergrate UIKitSwiftUI Basic ViewsSwiftUI ButtonsSwiftUI ColorSwiftUI GradientSwiftUI DatePickerSwiftUI Form ValidationSwiftUI FormSwiftUI SliderSwiftUI StepperSwiftUI TextEditorSwiftUI GridSwiftUI GroupsSwiftUI ListSwiftUI Navigation BarSwiftUI ScrollViewSwiftUI SpacersSwiftUI StacksSwiftUI Views And ModifiersSwiftUI Gestures AdvancedSwiftUI Gestures BasicSwiftUI Gestures CombinedSwiftUI GesturesSwiftUI Custom Row Swipe ActionsSwiftUI HapticsSwiftUI HitTestingSwiftUI InteractionsSwiftUI Searchable ViewsSwiftUI Absolute PositioningSwiftUI AlignmentSwiftUI AlignmentGuideSwiftUI Custom AlignmentSwiftUI GeometryReader BasicsSwiftUI GeometryReader UsageSwiftUI How Layout WorksSwiftUI Layout TechniquesSwiftUI Multiple Views Side by SideSwiftUI Switch View with EnumsSwiftUI Switch View with EnumsSwiftUI NavigationSwift NavigationLinkSwiftUI SheetsSwiftUI TabsSwiftUI BindingSwiftUI Environment WrapperSwiftUI FetchRequest WrapperSwiftUI FocusState WrapperSwiftUI MainActor WrapperSwiftUI ObservableObject WrapperSwiftUI ObservedObject WrapperSwiftUI Property WrappersSwift ObservableObject Manually Publishing ChangesSwiftUI State WrapperSwiftUI StateObject WrapperSwiftUI ViewBuilder WrapperSwiftUI ScenesSwiftUI AlertsSwiftUI Confirmation DialogSwiftUI Context MenuSwiftUI Popup WindowsSwiftUI SheetsCS193p Emoji ArtCS193p Matching GameCS193p Set GameStanford CS193pSwift Basic Data TypesSwift BooleanSwift FloatSwift IntSwift StringSwift ArraySwift ClassSwift Complex Data TypesSwift DictionarySwift EnumSwift SetSwift StructSwift Animating GesturesSwift Animating TransitionsSwift Animations TypesSwift animationsSwift Customize AnimationsSwift URLSessionSwift NetworkingSwift URLSessionSwift Comparable ProtocolsSwift ProtocolsSwift Codable @Published ComformanceSwift CodableSwift Documents DirectorySwift StorageSwift UserDefaultsSwiftSwift App BundleSwift Package DependenciesSwift TimerSwift ToolsSwift Basic TechniquesSwift ClosuresSwift ConditionsSwift ExtensionsSwift FunctionsSwift LoopsSwift OptionalsSwift Variable and ConstantsSwift TechniquesSwift Type AnnotationSwift Unique TypesSwift Result TypeSwift Framework CoreDataSwift Framework CoreImageSwift Framework LocalAuthenticationSwift Framework MLSwift Framework MapKitSwift Framework UNUserNotificationCenterSwift Framework Local NotificationsSwift Framework Remote NotificationsSwift Framework UserNotificationsSwift FrameworksSwiftUI FundamentalsSwiftUI WindowGroupA note about catsConsistency is keyHow to ThinkMove your body every dayYour first seedImage InterpolationCreate accessible spatial experiencesDevelop your first immersive appFundamental Design VisionOSGet started with building apps for spatial...Getting Started visionOSBuild great games for spatial computingCreate a great spatial playback experienceDeliver video content for spatial experiencesDiscover Metal for immersive appsStep Eight visionOSExplore rendering for spatial computingMeet Core Location for spatial computingMeet RealityKit TraceOptimize app power and performance for spatial...Step Five visionOSWhat’s new in Xcode 15Design considerations for vision and motionDesign for spatial inputDesign for spatial user interfacesDesign spatial SharePlay experiencesExplore immersive sound designStep Four visionOSDiscover Quick Look for spatial computingMeet Safari for spatial computingRediscover Safari developer featuresStep Nine visionOSWhat’s new in Safari extensionsBring your Unity VR app to a fully immersive spaceCreate immersive Unity appsExplore App Store Connect for spatial computingStep Seven visionOSExplore materials in Reality Composer ProExplore the USD ecosystemMeet Reality Composer ProStep Six visionOSWork with Reality Composer Pro content in XcodeBuild spatial SharePlay experiencesCreate 3D models for Quick Look spatial...Enhance your iPad and iPhone apps for the Shared...Run your iPad and iPhone apps in visionOSStep Ten visionOSBuilding Spatial Experiences with RealityKitEnhance your spatial computing app with RealityKitEvolve your ARKit app for spatial experiencesMeet ARKit for spatial computingStep Three visionOSElevate your windowed app for spatial computingGo beyond the window with SwiftUIMeet SwiftUI for spatial computingStep Two visionOSTake SwiftUI to the next dimensionTen Steps Overview of visionOS By AppleCreate multiple windows in VisionOSTap and Drag Spatial Gesture in VisionOSVisionOS Basic TutorialsvisionOS Documentation SeriesVisionOS Bear Balloon Reverse Gravity No CollisionVisionOS QuestionsWhy attend WWDCNew to WWDC