'Crash on MDLLightProbe

I was trying to bake an MDLLightProbe but the app is crashing. I have stripped down the code to bare minimum but still getting the same crash. Attaching the code and the stack.

    SCNNode *ambientLight = [SCNNode node];
    ambientLight.light = [SCNLight light];
    ambientLight.light.type = SCNLightTypeAmbient;
    ambientLight.light.color = [NSColor whiteColor];
    ambientLight.light.intensity = 1000.0;

    MDLLight *light = [MDLLight lightWithSCNLight:ambientLight.light];
    NSArray<MDLLight*> *lights = [NSArray arrayWithObjects: light, nil];

    
    MDLTransform* t = [[MDLTransform alloc] initWithIdentity];

    SCNNode* sph = [SCNNode node];
    sph.geometry = [SCNSphere sphereWithRadius:1.];
    sph.position = SCNVector3Make(1., 0.1, 0.);
    sph.geometry.firstMaterial.diffuse.contents = [NSColor grayColor];

    NSArray<MDLObject*> *obs = [NSArray arrayWithObjects: sph, nil];
    MDLLightProbe *probe2 = [MDLLightProbe lightProbeWithTextureSize:256 forLocation:t lightsToConsider: lights objectsToConsider:obs reflectiveCubemap:nil irradianceCubemap:nil];
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x66736e617288)
    frame #0: 0x00007ff803415bdd libobjc.A.dylib`objc_msgSend_stret + 29
    frame #1: 0x00007ff90b3bb094 SceneKit`-[SCNNode transform] + 38
    frame #2: 0x00007ff9169e5b53 ModelIO`___lldb_unnamed_symbol16530$$ModelIO + 107
    frame #3: 0x00007ff9169e5c25 ModelIO`___lldb_unnamed_symbol16531$$ModelIO + 9
    frame #4: 0x00007ff916a07f5d ModelIO`___lldb_unnamed_symbol16765$$ModelIO + 459
    frame #5: 0x00007ff91691eff7 ModelIO`___lldb_unnamed_symbol14669$$ModelIO + 552

xcode 13.3.1 macOS 12.3.1 . Any help is appreciated. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source