In looking into #2991, I noticed that overall, style validation consumes a non-neglible amount of resources at startup. In addition to #3149 and #3151, for styles loaded via mapbox.com APIs, we should skip validation entirely, because the APIs themselves enforce validity.
Could this be implemented as a setting (rather than caring about tile domain)?
Add something like skip_style_validation to map instantiation that defaults to False, but can be set to True if the user is certain their styles are valid.
Perhaps we could sniff for a value like style.metadata.skipValidation
I like @lucaswoj's proposal. That way an application (such as my own) that switches client side styles frequently can skip style validation as well. Perhaps it even would be possible to have the style validation process cache its own outcome via a property on the style in the line of style.metadata.isValid which would be removed upon any mutation on the style. That way style validation wouldn't have to be carried out on non-mutated styles.
I realised my own proposal wouldn't work for any mutations you would carry out on the style object directly, but I still like the idea that clients can skip validations at their own will.
How about making it an API option, rather than a metadata option? map.setStyle(..., {validate: false})
@jfirebaugh That would work, but as I understood your initial proposal you would like to have official Mapbox styles skip validation automatically, which perhaps is trickier if not part of the style definition but part of the API.
Another approach would be to have "development mode" (validate everything) and "production mode" (skip all validations) settings at the global level.
I think we want a granular option like {validate: false}.
setStyle (if no validate option is present) can depend on the style URL (disabled for mapbox:// URLs).setStyle can pass {validate: false} to the methods to which it delegates, fixing #3151.{validate: false} for performance-critical calls they are sure are valid, and keep it in place in general for safety.{validate: false}, fixing #3149.Could this be implemented as a setting (rather than caring about tile domain)?
Add something like
skip_style_validationto map instantiation that defaults to False, but can be set to True if the user is certain their styles are valid.
The other way around I assume? ;) Set to false if the user is uncertain...
Most helpful comment
How about making it an API option, rather than a metadata option?
map.setStyle(..., {validate: false})