Metal and NVIDIA graphic driver

Hi,

A user sent us a crash report that indicates an error occurring just after loading the default Metal library of our app.

Application Specific Information:
Crashing on exception: *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array

The report pointed me to these (simplified) lines of codes in the library setup:

_vertexFunctions        = [[NSMutableArray alloc] init];
_fragmentFunctions      = [[NSMutableArray alloc] init];
id<MTLLibrary> library  = [device newDefaultLibrary];

2 vertex shaders and 5 fragment shaders are then loaded and stored in these two arrays using this method:

-(BOOL) addShaderNamed:(NSString *)name library:(id<MTLLibrary>)library isFragment:(BOOL)isFragment {
    
    id shader  = [library newFunctionWithName:name];
    if (!shader) {
        ALOG(@"Error : Unable to find the shader named : “%@”", name);
        return NO;
    }
    [(isFragment ? _fragmentFunctions : _vertexFunctions) addObject:shader];
    return YES;
}

As you can see, the arrays are not filled if the method fails... however, a few lines later, they are used without checking if they are really filled, and that causes the crash...

But this coding error doesn't explain why no shader of a certain type (or both types) have been added to the array, meaning: why -newFunctionWithName: returned nil for all given names (since the implied array appears completely empty)?

Clue

This error has only be detected once by a user running the app on macOS 10.13 with a NVIDIA Web Driver instead of the default macOS graphic driver. Moreover, it wasn't possible to reproduce the problem on the same OS using the native macOS driver.

So my question is: is it some known conflicts between NVIDIA drivers and the use of Metal libraries? Or does this case would require some specific options in the Metal implementation?

Any help appreciated, thanks!

Metal and NVIDIA graphic driver
 
 
Q