dart-lang / web

Lightweight browser API bindings built around JS static interop.
https://pub.dev/packages/web
BSD 3-Clause "New" or "Revised" License
135 stars 23 forks source link

WebGL create*() methods return nullable objects, but most are not nullable in the IDL and specification #314

Open denniskaselow opened 1 month ago

denniskaselow commented 1 month ago

For example createBuffer():

https://github.com/dart-lang/web/blob/8478cd27d574249eca3d41f9135458dfda2762c8/web/lib/src/dom/webgl1.dart#L1098

vs IDL

https://github.com/w3c/webref/blob/15065116311262f763dc57d5bd0b2f1f5356fc20/ed/idl/webgl1.idl#L564

and specification: https://registry.khronos.org/webgl/specs/latest/1.0/#5.14.5

Only createShader() should return a nullable object.

denniskaselow commented 1 month ago

I just realized that the change in the IDL is rather recent. It was introduced a few months ago with version 3.52.1 (package:web is on 3.49.0 if the readme is correct) but they weren't nullable in dart:web_gl and that's why I was surprised.

EDIT: looking at the spec, it was changed to nullable in 2014, and now in July 2024 back to not nullable

srujzs commented 1 month ago

Yup, looks like this is a matter of updating the Web IDL version we use. I believe there are other breaking changes that would get pulled in with this, so we may wait a little while before we release a 2.0.0 in case we want to get other breaking changes in at the same time (and also remove some deprecations!).

dart:web_gl and the other dart: web libraries were based on stale Chrome IDL files that were last synced ~2017. Looking at the definitions in third_party/WebCore in the Dart SDK, createBuffer was non-nullable then.