newCommandQueue got nil

I am using Metal for rendering, and when calling the newCommandQueue interface of Metal, there is a certain probability that I will get a nil return value. However, when I call the MTLCreateSystemDefaultDevice interface, I can get a non-empty return value, which means my device supports Metal. I would like to ask what causes the newCommandQueue to return nil? Is there any way to avoid this situation? Thank you.

here is the code

if (self = [super init]) {
    self.device = MTLCreateSystemDefaultDevice();
    if (!self.device) {
        return nil;
    }
    id<MTLLibrary> defaultLibrary = [self.device newLibraryWithSource:[self shaderSource] options:nil, error:nil];
    if (!defaultLibrary) {
        return nil;
    }
    command_queue = [self.device newCommandQueue];
    if (!command_queue) {
        return nil;
    }
    return self;
}
newCommandQueue got nil
 
 
Q