Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find name 'VideoFrame' error #127

Closed
mikeny07 opened this issue Jun 16, 2023 · 7 comments · Fixed by #129
Closed

Cannot find name 'VideoFrame' error #127

mikeny07 opened this issue Jun 16, 2023 · 7 comments · Fixed by #129

Comments

@mikeny07
Copy link

I have a WebGPU project that runs fine using @webgpu/types version 0.1.31. However, when updating to 0.1.33, I got the following error when running the same project:

node_modules/@webgpu/types/dist/index.d.ts:83:7 - error TS2304: Cannot find name 'VideoFrame'.

83 | VideoFrame
~~~~~~~~~~

node_modules/@webgpu/types/dist/index.d.ts:807:7 - error TS2304: Cannot find name 'VideoFrame'.

807 | VideoFrame;
~~~~~~~~~~

The error seems nothing to do with my code. How to fix it?

@kainino0x
Copy link
Collaborator

Ah, I forgot about this problem when we landed the additional VideoFrame overload.
This requires @types/dom-webcodecs. Let try a fix for this.

@kainino0x
Copy link
Collaborator

@mikeny07 could you test if the PR #128 fixes this issue for you? I think you can test it out by replacing for example
"@webgpu/types": "0.1.33",
with
"@webgpu/types": "kainino0x/types#cd1df383c20574709c80d18cb31d14f482bb5795",

@mikeny07
Copy link
Author

with:

"@webgpu/types": "kainino0x/types#cd1df383c20574709c80d18cb31d14f482bb5795",

I got more errors when running the project:

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:56:14 - error TS2304: Cannot find name 'AvcBitstreamFormat'.

56 format?: AvcBitstreamFormat | undefined;
~~~~~~~~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:74:11 - error TS2552: Cannot find name 'EncodedVideoChunkType'. Did you mean 'EncodedVideoChunk'?

74 type: EncodedVideoChunkType;
~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:266:13
266 declare var EncodedVideoChunk: {
~~~~~~~~~~~~~~~~~
'EncodedVideoChunk' is declared here.

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:137:13 - error TS2304: Cannot find name 'AlphaOption'.

137 alpha?: AlphaOption | undefined;
~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:140:19 - error TS2304: Cannot find name 'VideoEncoderBitrateMode'.

140 bitrateMode?: VideoEncoderBitrateMode | undefined;
~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:147:19 - error TS2304: Cannot find name 'LatencyMode'.

147 latencyMode?: LatencyMode | undefined;
~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:173:13 - error TS2304: Cannot find name 'VideoPixelFormat'.

173 format: VideoPixelFormat;
~~~~~~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:185:13 - error TS2304: Cannot find name 'AlphaOption'.

185 alpha?: AlphaOption | undefined;
~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:214:21 - error TS2304: Cannot find name 'CodecState'.

214 readonly state: CodecState;
~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:231:21 - error TS2304: Cannot find name 'CodecState'.

231 readonly state: CodecState;
~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:262:20 - error TS2552: Cannot find name 'EncodedVideoChunkType'. Did you mean 'EncodedVideoChunk'?

262 readonly type: EncodedVideoChunkType;
~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:266:13
266 declare var EncodedVideoChunk: {
~~~~~~~~~~~~~~~~~
'EncodedVideoChunk' is declared here.

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:329:21 - error TS2304: Cannot find name 'CodecState'.

329 readonly state: CodecState;
~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:346:21 - error TS2304: Cannot find name 'CodecState'.

346 readonly state: CodecState;
~~~~~~~~~~

node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:368:22 - error TS2304: Cannot find name 'VideoPixelFormat'.

368 readonly format: VideoPixelFormat | null;
~~~~~~~~~~~~~~~~

Found 13 errors in the same file, starting at: node_modules/@types/dom-webcodecs/webcodecs.generated.d.ts:56

@mikeny07 mikeny07 changed the title Cannot fnd name 'VideoFrame' error Cannot find name 'VideoFrame' error Jun 17, 2023
@kainino0x
Copy link
Collaborator

kainino0x commented Jun 21, 2023

It appears that @types/dom-webcodecs>0.1.6 removed some definitions that have been merged in upstream TypeScript and therefore require TypeScript >5.1.3.

It seems you can use this page to determine which version of the package to use for your version of TypeScript:
https://www.npmjs.com/package/@types/dom-webcodecs?activeTab=versions

I think you'll have to install that particular package version explicitly. I arbitrarily chose ^0.1.5 as the min version but I can probably loosen that to ^0.1.3.

@kainino0x
Copy link
Collaborator

Attempting this further, I don't think there's a way this package can express its dependency on @types/dom-webcodecs due to the complex relationship between those dependencies and TypeScript. TypeScript 5.1 actually includes WebCodecs upstream and doesn't need @types/dom-webcodecs anymore.

I'm adding tests/examples that make sure the types build and work in various typescript versions.

@kainino0x
Copy link
Collaborator

Please reopen this if the latest release 0.1.34 with the version-appropriate sibling dependency on @types/dom-webcodecs doesn't work for you.

@mikeny07
Copy link
Author

using @webgpu/types 0.1.34 and typescript 4.6.3, I got the error:

Found 2 errors in the same file, starting at: node_modules/@webgpu/types/dist/index.d.ts:83

after updating typescript to 5.1.3, the project compiles and runs successfully without any error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants