installWebGpuAdapterInfoShim function
void
installWebGpuAdapterInfoShim()
Implementation
void installWebGpuAdapterInfoShim() {
try {
final g = globalContext;
final ga = g.getProperty<JSObject?>('GPUAdapter'.toJS);
if (ga == null || ga.isUndefinedOrNull) return;
final proto = ga.getProperty<JSObject?>('prototype'.toJS);
if (proto == null || proto.isUndefinedOrNull) return;
if (proto.has('info')) return;
final descriptor = JSObject();
descriptor.setProperty('configurable'.toJS, true.toJS);
descriptor.setProperty(
'get'.toJS,
(() {
final info = JSObject();
for (final field in const [
'vendor',
'architecture',
'device',
'description',
]) {
info.setProperty(field.toJS, ''.toJS);
}
info.setProperty('subgroupMinSize'.toJS, 0.toJS);
info.setProperty('subgroupMaxSize'.toJS, 0.toJS);
info.setProperty('isFallbackAdapter'.toJS, false.toJS);
return info;
}).toJS,
);
_defineProperty(proto, 'info'.toJS, descriptor);
} catch (_) {
// A browser that refuses the property leaves the glue exactly as it was.
}
}