WICG / shape-detection-api

Detection of shapes (faces, QR codes) in images
https://wicg.github.io/shape-detection-api
Other
306 stars 36 forks source link

Why does this spec use dictionaries containing FrozenArray<>s, instead of sequence<>s? #100

Closed domenic closed 7 months ago

domenic commented 8 months ago

We're hoping to remove support for dictionaries containing frozen arrays, in https://github.com/whatwg/webidl/issues/1399. It's not clear why this spec makes the array objects immutable, when the dictionaries themselves are (like all dictionaries) mutable.

reillyeon commented 8 months ago

I recall some old guidance around using frozen arrays in return values. It might've been misapplied here.

Is there any compat risk in changing this?

inexorabletash commented 8 months ago

The IDL issue calls out the plausible use case of "The exception is if some of these APIs are caching the FrozenArray<>s to avoid creating new JS Array values each time, for performance reasons." - a quick glance at the Chromium impl it doesn't look like we're caching.

The compat risk should be minimal - it would depend on a caller receiving the array via the output dictionary, and relying on it being immutable. Not impossible, but unlikely.