TapGesture stops responding on ViewAttachmentComponent after disabling or removing and re-adding the Entity (visionOS 26)

Issue

When an Entity with a ViewAttachmentComponent is:

  • disabled using isEnabled = false
  • removed using removeFromParent()

and then enabled or added back again, the attached SwiftUI view is rendered correctly, but tap interactions stop working.

Specifically:

  • Button actions inside the attached view do not fire
  • TapGesture closures on child views do not respond

Expected Behavior

Tap interactions inside the attached view should continue to work after the Entity is re-enabled or re-added.

Actual Behavior

After being disabled or removed once, all tap interactions stop responding.

Comparison

When displaying the same SwiftUI view using RealityViewAttachments, this issue does not occur. Removing and re-displaying the attachment still allows taps to work correctly.

Reproduction

Attached sample code reproduces the issue:

  • A RealityView with an Entity that has a ViewAttachmentComponent
  • The attached SwiftUI view contains a Toggle
  • The toggle updates isEnabled on the Entity
  • After toggling off and on, tap interactions stop responding

Environment

  • Xcode 26
  • visionOS 26

Question

Is this expected behavior of ViewAttachmentComponent, or a bug? Is there a recommended way to temporarily hide or disable an Entity with ViewAttachmentComponent without breaking tap interactions?

import SwiftUI
import RealityKit

struct GestureTestView: View {
    
    @State var sampleEnabled = true
    @State var sampleEntity: Entity?
    
    var body: some View {
        RealityView { contents, attachments in
            
            // After deleting and re-displaying it, taps no longer respond.
            let sample = Entity(components: ViewAttachmentComponent(rootView: SampleView()))
            
            // Executed successfully
            //let sample = attachments.entity(for: "SampleView")!
            
            contents.add(sample)
            sample.position = [0, 1.2, -1]
            sampleEntity = sample
            
            let toggleButton = Entity(components: ViewAttachmentComponent(rootView: ToggleButtonView(isOn: $sampleEnabled)))
            contents.add(toggleButton)
            toggleButton.position = [0, 1, -1]
            
        } update: { _, _ in
            // run update closure
            print(sampleEnabled)
            
            // update sample entity enable
            sampleEntity?.isEnabled = sampleEnabled
        } attachments: {
            Attachment(id: "SampleView") {
                SampleView()
            }
        }
    }
}

struct ToggleButtonView: View {
    
    @Binding var isOn: Bool
    
    var body: some View {
        VStack {
            Toggle(isOn: $isOn) {
                Text("Toggle")
            }
        }
        .padding()
        .glassBackgroundEffect()
    }
}

struct SampleView: View {
    var body: some View {
        VStack {
            Button {
                print("Hello, World!")
            } label: {
                Text("Hello, World!")
                    .padding()
            }
        }
        .padding()
        .glassBackgroundEffect()
    }
}

#Preview(immersionStyle: .mixed) {
    GestureTestView()
}

Hey @u_kudo,

This is an issue we're aware of (FB20792470), but we're not aware of any recommended workaround so far. If you find something that helps you avoid the issue, please share it with the community by posting it here.

Even though we're aware of this issue, we still encourage you to open a bug report, and post the FB number here once you do. The specific info you include your bug report might help our investigation, and filing the bug report you to get notified when it is resolved.

Bug Reporting: How and Why? explains how you can open a bug report.

Thanks,
Michael

TapGesture stops responding on ViewAttachmentComponent after disabling or removing and re-adding the Entity (visionOS 26)
 
 
Q