Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Set purgeability state to volatile while resource is in use by a Command Buffer #1456

Open
AJTech2002 opened this issue Jan 30, 2025 · 0 comments

Comments

@AJTech2002
Copy link

AJTech2002 commented Jan 30, 2025

Error:

-[MTLDebugTexture setPurgeableState:]:832: failed assertion `Set Purgeable Stage Validation Cannot set purgeability state to volatile while resource is in use by a command buffer.'

The following error is thrown in the XCode console, referring to line 936 within xr/Source/ARKit/XR.mm for the following lines:

[currentCommandBuffer addCompletedHandler:^(id<MTLCommandBuffer>) {
                    if (cameraTextureY != nil) {
                        [cameraTextureY setPurgeableState:MTLPurgeableStateEmpty];
                    }

                    if (cameraTextureCbCr != nil) {
                        [cameraTextureCbCr setPurgeableState:MTLPurgeableStateEmpty];
                    }
                }];

Originally I was getting this error as soon as the WebXR session launched however we tried replacing it with the following code which reduces the frequency of the crash & allows us to run the XR session however it still occurs intermittently:

[currentCommandBuffer addCompletedHandler:^(id<MTLCommandBuffer>) {
                    id<MTLCommandBuffer> cleanupCommandBuffer = [commandQueue commandBuffer];

                    [cleanupCommandBuffer addCompletedHandler:^(id<MTLCommandBuffer>) {
                        if (cameraTextureY && cameraTextureY.allocatedSize > 0) {
                            NSLog(@"Setting cameraTextureY to purgeable.");
                            [cameraTextureY setPurgeableState:MTLPurgeableStateEmpty];
                        }
                        if (cameraTextureCbCr && cameraTextureCbCr.allocatedSize > 0) {
                            NSLog(@"Setting cameraTextureCbCr to purgeable.");
                            [cameraTextureCbCr setPurgeableState:MTLPurgeableStateEmpty];
                        }
                    }];

                    [cleanupCommandBuffer commit];
                }];

This occurs while within an XR Session and can occur for a variety of reasons such as loading a large 3D model while in session.

It seems to occur at random, however the pattern is this occurs whenever there is a significant frame drop. Once this error occurs the XR session freezes.

Platform: iOS 17.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant