SafariWebView in ImmersiveSpace with hand tracking

Is it possible to show a SafariWebView in an ImmersiveSpace with hand tracking enabled?

I have an app with an initialView that launches an immersive space and opens a SafariView. I noticed that hand tracking stops working when I open the SafariView, but not when I open the TestView (which is just an empty window).

Here's the Scene:

var body: some Scene {

    WindowGroup(id: "control") {
        InitialView()
    }.windowResizability(.contentSize)
    
    WindowGroup(id: "test") {
        TestView()
    }.windowResizability(.contentSize)
    
    WindowGroup(id: "safari") {
        SafariView(url: URL(string: "some URL")!)
    }

    ImmersiveSpace(id: "immersiveSpace") {
        ImmersiveView()
    }
}

Hi @waba

It's not clear to me what is going on in your code snippet, since "SafariView" is not a type in RealityKit or SwiftUI, et al. Are you referring to WKWebView? If so, then the quick answer to your question is yes, you can show a WKWebView in an ImmersiveView while hand tracking is enabled.

If you share more info about the experience you are trying to create I might be able to help troubleshoot a bit more. In the quick app I put together before writing this reply, I was able to use AnchorEntity and attachments to attach a browser window to my hand in an ImmersiveView while a SpatialTrackingSession was running. But maybe you're doing something more involved?

Note: you may be using SFSafariViewController, in which case I think the solution to your issue is to switch to a WKWebView implementation. From the docs:

Present an SFSafariViewController when you don’t need to customize or interact with the web content. After you present the content, interactions with the web content occur solely within the view controller. When the person dismisses the view controller, control returns to your app’s interface. If you need to customize the controls of the web interface, or you want to interact with content in that interface, display the content using a WKWebView object instead.

Let me know if this helps!

SafariWebView in ImmersiveSpace with hand tracking
 
 
Q