How do I use Canvas to build performant apps?
Asked on 2024-07-30
1 search
To build performant apps using Canvas, you can leverage several insights and techniques from different WWDC sessions:
-
Optimize 3D Assets:
- Polygon Count: Keep your polygon count low, focusing on how many triangles can be seen at one time. As a general guideline, aim for no more than 500,000 triangles for an immersive scene.
- Texture Memory: Efficiently use your texture memory by packing your textures and taking advantage of compression.
- Materials and Shaders: Use unlit materials and baked textures whenever possible to reduce the rendering load on the GPU.
- Environment Radiance Node: Consider using this when unlit materials aren't enough.
- Skybox Textures: Keep your skybox textures large but your IBL (Image-Based Lighting) texture small.
For more details, you can refer to the session Optimize your 3D assets for spatial computing.
-
Swift Performance:
- Algorithmic Improvements: Often, performance issues can be addressed by improving algorithms rather than delving into low-level code optimizations.
- Measurement Tools: Use tools like Instruments to measure performance and identify bottlenecks.
- Memory Management: Pay attention to memory allocation and layout, as well as value copying, to ensure efficient use of resources.
For a deeper dive into performance considerations, check out the session Explore Swift performance.
-
Spatial Drawing with RealityKit:
- Spatial Tracking: Set up spatial tracking to understand hand and environment data, which is crucial for interactive and immersive applications.
- UI Control: Build a user interface that allows control over the brush and canvas, and customize the UI appearance on hover.
- Brush Geometry: Use RealityKit APIs to efficiently generate brush geometry with Metal.
For more information, see the session Build a spatial drawing app with RealityKit.
-
Apple Pencil Integration:
- Feedback Generators: Use UI canvas feedback generators and sensory feedback from SwiftUI to provide haptic feedback, making the canvas more interactive and responsive.
- Barrel Roll Angle: Utilize the barrel roll angle feature to make strokes more expressive.
For more details, refer to the session Squeeze the most out of Apple Pencil.
By combining these techniques, you can build performant and responsive applications that leverage the full capabilities of Canvas and related technologies.

Deploy machine learning and AI models on-device with Core ML
Learn new ways to optimize speed and memory performance when you convert and run machine learning and AI models through Core ML. We’ll cover new options for model representations, performance insights, execution, and model stitching which can be used together to create compelling and private on-device experiences.

Optimize your 3D assets for spatial computing
Dive into an end-to-end workflow for optimized 3D asset creation. Discover best practices for optimizing meshes, materials, and textures in your digital content creation tool. Learn how to harness shader graph, baking, and material instances to enhance your 3D scene while optimizing performance. Take advantage of native tools to work more effectively with your assets and improve your app’s performance.

Build immersive web experiences with WebXR
Discover how WebXR empowers you to add fully immersive experiences to your website in visionOS. Find out how to build WebXR experiences that take full advantage of the input capabilities of visionOS, and learn how you can use Simulator to test WebXR experiences on macOS.
