[VisionOS] Crash on Present / Show GameCenter UI on VisionOS

I'm trying to display the native GameCenter interface from Unity (I've already tried Bounded and Unbouded Volume Mode, that is, with and without Full Immersive Mode) but I can't display this interface.

If I use Unity's SocialAPI (https://docs.unity3d.com/ScriptReference/Social.ShowLeaderboardUI.html), nothing is displayed, and I get the following message in XCode (simulator):

[u 9C225095-F55E-42CC-8136-957279631DF3:m (null)] [com.apple.GameCenterUI.GameCenterDashboardExtension(1.0)] Connection to plugin interrupted while in use.

setViewControllers:animated: called on <GKGameCenterViewController 0x106825600> while an existing transition or presentation is occurring; the navigation stack will not be updated.
Type: Notice | Timestamp: 2023-12-08 12:13:50.585973+01:00 | Process: leaderboard-test | Library: UIKitCore | TID: 0x3e57bd

viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
Type: Notice | Timestamp: 2023-12-08 12:13:50.586997+01:00 | Process: leaderboard-test | Library: UIKitCore | TID: 0x3e57bd

[u 9C225095-F55E-42CC-8136-957279631DF3:m (null)] [com.apple.GameCenterUI.GameCenterDashboardExtension(1.0)] Connection to plugin invalidated while in use.
Type: Error | Timestamp: 2023-12-08 12:13:50.588393+01:00 | Process: leaderboard-test | Library: PlugInKit | Subsystem: com.apple.PlugInKit | Category: lifecycle | TID: 0x3e5a18

If I try to do it using Apple's plugin for GameCenter (GameKitWrapper) adapted to VisionOS, the application crashes with the following error:

"Presentations are not permitted within volumetric window scenes."

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Presentations are not permitted within volumetric window scenes.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001804a510c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x0000000180082f50 objc_exception_throw + 56
	2   UIKitCore                           0x0000000184bc2798 -[UIViewController _presentViewController:withAnimationController:completion:] + 1136
	3   UIKitCore                           0x0000000184bc4000 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 88
	4   UIKitCore                           0x0000000184bc42d0 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 484
	5   UIKitCore                           0x0000000184bc3f6c -[UIViewController _presentViewController:animated:completion:] + 160
	6   UIKitCore                           0x0000000184bc4374 -[UIViewController presentViewController:animate
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Presentations are not permitted within volumetric window scenes.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001804a510c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x0000000180082f50 objc_exception_throw + 56
	2   UIKitCore                           0x0000000184bc2798 -[UIViewController _presentViewController:withAnimationController:completion:] + 1136
	3   UIKitCore                           0x0000000184bc4000 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 88
	4   UIKitCore                           0x0000000184bc42d0 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 484
	5   UIKitCore                           0x0000000184bc3f6c -[UIViewController _presentViewController:animated:completion:] + 160
	6   UIKitCore                           0x0000000184bc4374 -[UIViewController presentViewController:animated:completion:] + 140
	7   GameKitWrapper                      0x00000001057aa864 $s14GameKitWrapper34GKGameCenterViewController_Present7pointer6taskId9onSuccessySv_s5Int64VyAGXCtF ...
)

The code that produces this crash is the following (trying to display the GameCenter UI):

let viewController = UIApplication.shared.windows.first!.rootViewController; viewController?.present(target, animated: true);

@_cdecl("GKGameCenterViewController_Present")
public func GKGameCenterViewController_Present
(
    pointer: UnsafeMutableRawPointer,
    taskId: Int64,
    onSuccess: @escaping SuccessTaskCallback
)
{
    let target = Unmanaged<GKGameCenterViewController>.fromOpaque(pointer).takeUnretainedValue();
    _currentPresentingGameCenterDelegate = GameKitUIDelegateHandler(taskId: taskId, onSuccess: onSuccess);
    target.gameCenterDelegate = _currentPresentingGameCenterDelegate;

#if os(iOS) || os(tvOS) || os(visionOS)
    let viewController = UIApplication.shared.windows.first!.rootViewController;
    viewController?.present(target, animated: true);
#endif
}

Is there a way to present the GameCenter UI overlaid on the Unity app?

Post not yet marked as solved Up vote post of UnrealMitch Down vote post of UnrealMitch
651 views

Replies

Hi,

I've been dealing with the same problem. As far as I figured out, we need to create WindowGroup with .plain parameter but it is in SwiftUI RealityKit, not Unity3D. Have you found any solution to this problem?

@UnrealMitch EDIT: A possible solution is setting window style Info.plist in Xcode.

Under "Application Scene Manifest", change "Preferred Default Scene Session Role" to "Window Application Session Role". At least, it is opening up Game Center Matchmaking View Controller in my project.

Regards, Melih