Interacting with virtual content blended with passthrough
At a glance
| Item | Summary |
|---|---|
| Purpose | Present a mixed immersion style space to draw content in a person’s surroundings, and choose how upper limbs appear with respect to rendered content. |
| App architecture | A C/Objective-C header, Metal, Swift sample with the source-visible chain Compositor_Services_InteractionApp → InteractionView → AppModel → Renderer → CompositorServices APIs. |
| Main patterns | Protocol-oriented abstraction, Actor isolation |
| Project style | 12 scanned source file(s) across C/Objective-C header, Metal, Swift, organized around ranked entry, type, and file boundaries. |
| Execution model | Source-visible boundaries: @MainActor, Task closure isolated to MainActor, Task, await suspension point, Sendable or @Sendable; none alone proves a background thread. |
| State/event model | Source-visible mechanisms: @Observable, SwiftUI state property wrapper. |
| Key frameworks/packages | CompositorServices, SwiftUI, simd, MetalKit, Spatial; these are source dependencies, not architecture labels. |
Project structure
Source bundle/
└── Compositor-Services-Interaction/
├── Compositor_Services_InteractionApp.swift
├── Renderer.swift
├── TintRenderer.swift
├── AppModel.swift
├── InteractionView.swift
├── PathCollection.swift
├── ImmersiveInteractionScene.swift
├── Bridging-Header.h
├── PathProperties.h
├── ShaderTypes.h
├── Shaders.metal
└── Uniforms.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: C/Objective-C header, Metal, Swift.
- The verified tree contains 4 project/configuration file(s) and 20 source declaration(s).
Overall architecture
flowchart LR
N1["Compositor_Services_InteractionApp"]
N2["InteractionView"]
N3["AppModel"]
N4["Renderer"]
N5["CompositorServices APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
N4 --> N5
Reference code
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:26 — architecture anchor
@main
struct InteractionApp: App {
// ...
@State private var appModel = AppModel()
// ...
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Compositor Services.
Ownership and state
classDiagram
InteractionApp *-- AppModel : appModel
RendererActor *-- RendererActor : shared
Renderer o-- AppModel : appModel
Renderer o-- PathCollection : pathCollection
Ownership evidence
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:29 — stored dependency or nearest verified ownership anchor
@main
struct InteractionApp: App {
// ...
@State private var appModel = AppModel()
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
InteractionApp |
AppModel (appModel) |
owns wrapper-managed state | Owning lexical scope |
RendererActor |
RendererActor (shared) |
creates and retains | App/module collaborators |
Renderer |
AppModel (appModel) |
stores or receives | Initialized by the owner; the binding is immutable |
Renderer |
PathCollection (pathCollection) |
stores or receives | Initialized by the owner; the binding is immutable |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Concurrency, scheduling, and thread safety
Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.
| Concern | Source mechanism | Verified placement or handoff | Evidence |
|---|---|---|---|
| Main isolation | @MainActor |
The cited annotation marks its attached declaration or closure as main-actor isolated. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:47 |
| Main isolation | Task closure isolated to MainActor |
The cited operation explicitly enters a main-actor-isolated region. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:47 |
| Task creation | Task |
The source creates an unstructured task; surrounding context determines inherited actor isolation. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:47 |
| Suspension boundary | await suspension point |
The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:49 |
| Transfer contract | Sendable or @Sendable |
The source declares a sendability boundary; this alone does not synchronize mutable state. | Compositor-Services-Interaction/PathCollection.swift:127 |
@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.
Reference code
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:47 — representative execution boundary
Task { @MainActor in
// ...
case .opened:
// ...
}State propagation, frameworks, and dependencies
Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.
| Category | Mechanism or module | Verified role | Evidence |
|---|---|---|---|
| State propagation | @Observable |
Observation macro publishes source-visible changes. | Compositor-Services-Interaction/AppModel.swift:11 |
| State propagation | SwiftUI state property wrapper |
A SwiftUI property wrapper supplies or observes UI state. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:29 |
| Source import | CompositorServices |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift:9 |
| Source import | SwiftUI |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/AppModel.swift:8 |
| Source import | simd |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/Renderer.swift:11 |
| Source import | MetalKit |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/PathCollection.swift:11 |
| Source import | Spatial |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/PathCollection.swift:9 |
| Source import | Metal |
The cited file imports this module; runtime use and architectural role are not inferred. | Compositor-Services-Interaction/Renderer.swift:9 |
receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.
Class and protocol design
Compositor-Services-Interaction/PathCollection.swift:16 — representative type boundary
@MainActor
private protocol Path {
var id: PathID { get }
var buffer: MTLBuffer { get }
var vertexCount: Int { get }
var parameters: PathProperties { get set }
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
InteractionApp |
Application entry and top-level composition | App |
Renderer |
Owns drawing, GPU, or presentation processing | Concrete collaborators/imported frameworks |
TintRenderer |
Owns drawing, GPU, or presentation processing | Concrete collaborators/imported frameworks |
TintDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
DrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
AppModel |
Feature data or observable state | Concrete collaborators/imported frameworks |
InteractionView |
User-interface presentation and input forwarding | View |
PathCollectionDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
PathDrawCommand |
Represents or runs a user/system command | Concrete collaborators/imported frameworks |
ImmersiveInteractionScene |
Scene lifecycle or scene-level composition | Scene |
The source explicitly defines local protocol relationships: CompletePath → Path, ActivePath → Path.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
isFirstLaunch (Compositor-Services-Interaction/AppModel.swift:14) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
showImmersiveSpace (Compositor-Services-Interaction/AppModel.swift:15) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
immersiveSpaceIsShown (Compositor-Services-Interaction/AppModel.swift:16) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
immersionStyle (Compositor-Services-Interaction/AppModel.swift:17) |
public |
The symbol is visible to importing modules. | Inference: make the declaration available across a module or target boundary. |
Reference code
Compositor-Services-Interaction/AppModel.swift:14 — representative boundary
@Observable
public class AppModel {
// ...
public var isFirstLaunch = true
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Application entry and top-level composition | InteractionApp |
The source’s App suffix makes this role explicit. |
| Represents or runs a user/system command | DrawCommand, PathCollectionDrawCommand, PathDrawCommand, TintDrawCommand |
The source’s Command suffix makes this role explicit. |
| Feature data or observable state | AppModel |
The source’s Model suffix makes this role explicit. |
| Owns drawing, GPU, or presentation processing | Renderer, TintRenderer |
The source’s Renderer suffix makes this role explicit. |
| Scene lifecycle or scene-level composition | ImmersiveInteractionScene |
The source’s Scene suffix makes this role explicit. |
| User-interface presentation and input forwarding | InteractionView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Protocol-oriented abstraction | Compositor-Services-Interaction/PathCollection.swift:28 |
A local protocol and concrete conformance create an explicit capability boundary. |
| Actor isolation | Compositor-Services-Interaction/Renderer.swift:34 |
A declared actor creates an explicit isolation boundary; its executor is not described as a background thread. |
Naming conventions
- Types: App: InteractionApp; Command: DrawCommand, PathCollectionDrawCommand, PathDrawCommand, TintDrawCommand; Model: AppModel; Renderer: Renderer, TintRenderer; Scene: ImmersiveInteractionScene; View: InteractionView.
- Protocols:
Path. - Methods:
makeConfiguration,defaultRenderPipelineDescriptor,memorylessTexture,getMultisampleRenderTarget,renderLoop,renderPassDescriptor,renderFrame,buildMetalVertexDescriptor. - Files:
Compositor-Services-Interaction/Renderer.swift,Compositor-Services-Interaction/TintRenderer.swift,Compositor-Services-Interaction/AppModel.swift,Compositor-Services-Interaction/InteractionView.swift,Compositor-Services-Interaction/PathCollection.swift,Compositor-Services-Interaction/ImmersiveInteractionScene.swift.
Architecture takeaways
Compositor_Services_InteractionAppis the main source-visible entry or composition anchor for this sample.- Framework work reaches CompositorServices, SwiftUI, simd, MetalKit through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- Local protocol relationships provide an explicit substitution boundary.
Source map
| Source file | Relevant symbols |
|---|---|
Compositor-Services-Interaction/Compositor_Services_InteractionApp.swift |
Cited implementation, @MainActor, Task closure isolated to MainActor, Task, await suspension point, SwiftUI state property wrapper, CompositorServices, ContentStageConfiguration, InteractionApp |
Compositor-Services-Interaction/PathCollection.swift |
Path, Cited implementation, Sendable or @Sendable, MetalKit, Spatial, CompletePath, ActivePath, Storage, PathCollection, Error, func, PathCollectionDrawCommand, PathDrawCommand |
Compositor-Services-Interaction/AppModel.swift |
Cited implementation, @Observable, SwiftUI, AppModel |
Compositor-Services-Interaction/Renderer.swift |
RendererActor, simd, Metal, Renderer |
Compositor-Services-Interaction/TintRenderer.swift |
TintRenderer, func, TintDrawCommand, DrawCommand |
Compositor-Services-Interaction/InteractionView.swift |
VisibilityState, IStyle, InteractionView |
Compositor-Services-Interaction/ImmersiveInteractionScene.swift |
ImmersiveInteractionScene |
Compositor-Services-Interaction/Bridging-Header.h |
Feature implementation |
Compositor-Services-Interaction/PathProperties.h |
Feature implementation |
Compositor-Services-Interaction/ShaderTypes.h |
Feature implementation |
Compositor-Services-Interaction/Shaders.metal |
Feature implementation |
Compositor-Services-Interaction/Uniforms.swift |
Feature implementation |