Unable to use ARGeoTrackingConfiguration when launching a new AR Session in the app - 15.4 (and 15.41.)

I am trying to set the AR View session configuration using ARGeoTrackingConfiguration but when I try and use the configuration, the camera does not activate. I am in Boston and have the proper device capabilities. I am running the app on my phone but it is still not working as expected.

Error in Debugger: 2022-04-06 13:07:29.249222-0400 GeoTrackingExample[9432:592012] [xpc.exceptions] <NSXPCConnection: 0x28338a3a0> connection to service with pid 8805 named com.apple.arkit.service.geoTracking: Exception caught during decoding of received selector techniqueDidOutputResultData:timestamp:context:, dropping incoming message. Exception: Exception while decoding argument 2 (#4 of invocation): <NSInvocation: 0x281813800>

Exception: value for key 'collaborationData' was of unexpected class 'NSSet' (0x22bbf5120) [/System/Library/Frameworks/CoreFoundation.framework].

I'm seeing this issue too, and I haven't been able to figure it out. I was able to reproduce the issue on the iOS 15.5 beta as well. I filed a feedback ticket about it (FB9971866)

It looks like this issue has been fixed in iOS 15.5 beta 2.

https://developer.apple.com/documentation/arkit/content_anchors/tracking_geographic_locations_in_ar

I'm seeing the same error from trying to build and run the Apple sample project. Building from Xcode 13.3.1 (13E500a) to iPhone 12 Pro Max running iOS 15.4.1 (19E258).

@glow you were able to build from Xcode 13.3.1 to 15.5b2 and the issue is fixed?

Do we know when the issue first started happening? Is this a 15.4.x bug?

Does anyone have the diff to get that Apple sample code project working correctly on 15.4.x?

Is there any workaround in code other than just gating users on 15.4.x from ever using ARGeoTrackingConfiguration?

@vanvoorden yes, I am building from Xcode 13.3.1 to my device on iOS 15.5 beta 2 and the issue is not reproducible anymore.

The issue started for me in iOS 15.4 (19E241).

I don't think there is a workaround in code. I filed a TSI on this issue and I was told "There is no workaround DTS can provide".

@glow it sounds like a bad bug. The sample code from 14.0 is breaking in 15.4. Apple DTS told us there is no workaround. That's… not a good sign.

It's possible the next version of Xcode builds and compiles to retcon a fix on 15.4.x. It's either an official fix from a new SDK, an unofficial fix in the form of discovering some kind of hacky private API to fix 15.4.x, or engineers just have to permanently gate their users from ARGeoTrackingConfiguration on 15.4.x.

#import <objc/runtime.h>

@interface SwizzledDecoder : NSObject

- (void)__validateAllowedClass:(Class)arg1 forKey:(id)arg2 allowingInvocations:(bool)arg3;

@end

@implementation SwizzledDecoder

- (void)__validateAllowedClass:(Class)arg1 forKey:(id)arg2 allowingInvocations:(bool)arg3 {
  if ([arg2 isEqualToString: @"collaborationData"]) {
    return;
  }
  return [self __validateAllowedClass: arg1 forKey: arg2 allowingInvocations: arg3];
}

@end

void NSXPCDecoderSwizzle(void) {
  //  https://nshipster.com/method-swizzling/
  
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    Class originalClass = NSClassFromString(@"NSXPCDecoder");
    Class swizzledClass = NSClassFromString(@"SwizzledDecoder");
    
    SEL originalSelector = @selector(_validateAllowedClass:forKey:allowingInvocations:);
    SEL swizzledSelector = @selector(__validateAllowedClass:forKey:allowingInvocations:);
    
    Method originalMethod = class_getInstanceMethod(originalClass, originalSelector);
    Method swizzledMethod = class_getInstanceMethod(swizzledClass, swizzledSelector);
    
    IMP originalImp = method_getImplementation(originalMethod);
    IMP swizzledImp = method_getImplementation(swizzledMethod);
    
    class_replaceMethod(originalClass,
                        swizzledSelector,
                        originalImp,
                        method_getTypeEncoding(originalMethod));
    class_replaceMethod(originalClass,
                        originalSelector,
                        swizzledImp,
                        method_getTypeEncoding(swizzledMethod));
  });
}

@glow this is some really awful code to at least get the ARGeoTrackingConfiguration back on screen displaying live camera capture on a device running 15.4.1.

@zackfromkeller does the method swizzling technique from below fix your build on 15.4.x?

@zackfromkeller I just went outside to try the hack and I'm able to see live camera capture and place geo anchors correctly on 15.4.1.

I tried building and installing from Xcode 13.4 (13F17a) to iOS 15.4.1 (19E258) and I still see the bug, which leads me to believe we're not going to see a retroactive fix from Apple in the new SDK to fix this for users on 15.4.x. Sad face.

Issue has been fixed in the release version of iOS 15.5

Unable to use ARGeoTrackingConfiguration when launching a new AR Session in the app - 15.4 (and 15.41.)
 
 
Q