Skip to content

Some work in progress on running the web-platform-tests suite for WebAudio #42

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

Merged
merged 40 commits into from
Dec 28, 2023

Conversation

orottier
Copy link
Collaborator

@orottier orottier commented Nov 25, 2023

  • figure out how to run wpt on our bindings
  • add all tests via a git submodule
  • add a stub implementation for missing bindings (e.g. OfflineAudioContext.suspend) to avoid some crashes
  • avoid all other crashes via the filter list
  • get the full suite to run
  • collect initial report
  • bindings for AudioListener
  • implement OfflineAudioContext.suspend
  • bindings for event listeners (edit)
  • make OfflineAudioContext.start_rendering take &self instead of self
  • check if we can run on all wpt files now
  • collect new report
  • can we drop the wpt fork?
  • start working on panics that occur
  • start working on failed assertions
  • start working on missing functionality

From https://github.com/web-platform-tests/wpt/tree/master/webaudio
Only leave 'the-audiobuffer-interface' for now.
Drop the crashtests/ dir as they hang the runner
@b-ma
Copy link
Collaborator

b-ma commented Nov 26, 2023

Coo thanks! Nice that you found https://www.npmjs.com/package/wpt-runner, porting all these things manually to make them work in Node like I tried was a mess

Will have a look soon, some Node stuff can be made more idiomatic and simplified

@orottier
Copy link
Collaborator Author

Will have a look soon, some Node stuff can be made more idiomatic and simplified

Yes please:)

Meanwhile I'm looking for a method to collect and track the test results.
Also to not pollute the repo too much I will probably replace the wpt files with a git submodule

@b-ma
Copy link
Collaborator

b-ma commented Nov 27, 2023

Ok it's a bit more node friendly now,

  • Moved all the code into './bin/test-harness.mjs`
  • You will need to npm install again (I added some deps) and then npm run wpt

Meanwhile I'm looking for a method to collect and track the test results.

I sketched something using the programmatic API, seems to be the way to go

Also to not pollute the repo too much I will probably replace the wpt files with a git submodule

Yup maybe that would be better, I think you didn't move all the files yet isn't it?

@orottier
Copy link
Collaborator Author

I sketched something using the programmatic API, seems to be the way to go

Thanks, definitely beats my grep .. | uniq -c approach.

think you didn't move all the files yet isn't it?

Indeed, we make the NodeJs runtime crash for many tests and the wpt runner is not properly isolated so the whole suite terminates. I will try to see if I can add some process level isolation to the test runner but since my javascript is terrible I probably won't make it work. Alternative is to put all crashing tests into the filter method of wpt-harness.js

@b-ma
Copy link
Collaborator

b-ma commented Nov 28, 2023

Hum I see, if you have one crashing test in mind maybe you could just add it, then I can try to see what we can do?

@orottier
Copy link
Collaborator Author

In mobile now, but e.g. analysernode invalid constructor tests (in ctor.html file)

@b-ma
Copy link
Collaborator

b-ma commented Nov 28, 2023

ok thanks will try to have a look later today

@b-ma
Copy link
Collaborator

b-ma commented Nov 28, 2023

Didn't really see how fix that in the test runner, seems more like a napi issue to me, so I fixed the issue in the lib itself (which is anyway what we want I guess :)

I also discriminated all errors of kind threw "Error" instead of EcmaScript error TypeError. from "real" errors in the output. So the test still not pass but at least we know this is not a behaviour problem. (I really thought a lot on how to fix this as at first sight it seems like an easy win, but I'm afraid the only solution is to rewrap absolutely everything in JS with try / catch to properly handle exotic error types, doable but so boring...)

All in all, at first sight:

  • Good new is that many issues comes from the bindings and not from the rust crate.
  • Sad new is that many issues comes from the bindings and not from the rust crate.

(I really like the fact that the ScriptProcessorNode is deprecated but that some tests rely on it :)

@orottier
Copy link
Collaborator Author

orottier commented Nov 28, 2023

Thanks for the additional work. Adding a different result type for "expected error ... but got error .." is very useful.

The wpt runner still crashes a lot for stupid reasons (missing bindings) but I also discovered a real bug, nice.

@orottier
Copy link
Collaborator Author

Slowly making progress, I managed to get into the the-audio-node-interface directory

I need these changes in the wpt repo, I will make a fork for that later

	deleted:    webaudio/the-audio-api/the-audiocontext-interface/audiocontext-not-fully-active.html
	deleted:    webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html
	deleted:    webaudio/the-audio-api/the-audiocontext-interface/constructor-allowed-to-start.html
	deleted:    webaudio/the-audio-api/the-audiocontext-interface/suspend-with-navigation.html
	deleted:    webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/cors-check.https.html
	deleted:    webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/no-cors.https.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	webaudio/resources/buffer-loader.js

That new file is created with cp wpt/webaudio/js/buffer-loader.js wpt/webaudio/resources.

I will create a tracking issue with all issues that make the runner crash (and hence why I deleted these 6 files)

@orottier
Copy link
Collaborator Author

Alright, I got the full suite to run.
For the rust project, you need the feature/prevent-wpt-crashes branch
For wpt, you need the https://github.com/orottier/wpt fork
Also I'm pushing some more stubs to this project

@orottier
Copy link
Collaborator Author

orottier commented Nov 30, 2023

For wpt @ web-platform-tests/wpt@83f318a
node bindings @ ce30937
rust impl @ orottier/web-audio-api-rs@0dab4c6

  RESULTS:
  - # pass: 3020
  - # fail: 1293
  - # type error issues: 230
  
files ignored: 21

@b-ma
Copy link
Collaborator

b-ma commented Dec 1, 2023

Cool, nice work!

Few question/remarks:

  • About the files you deleted in your wtp fork, it wasn't possible to just filter them in the wpt-harness.mjs script?
  • For the listener, we agree that the way you did it will break the kind of lazy instantiation we have in the rust side? I do not mean this should be fixed right away if this is the case, but maybe we should create a new issue to fix that

Let me know if you need some help on some points and/or when you think this is ready to merge

let obj = match napi_obj.0.as_ref() {
Some(v) => v,
None => return ctx.env.create_double(0.),
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit surprised about this change at first, but I guess it prevents crashing when we do something like this?

const result = await offlineContext.startRendering();
const now = offlineContext.currentTime

Seems that all this Option stuff was required to work around:

pub fn start_rendering_sync(self) -> AudioBuffer

Did you think it could be resolved at the rust level to have something like this instead:

pub fn start_rendering_sync(&self) -> AudioBuffer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely, let's change that API. And also implement https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-suspend because it is used so much in the wpt.

@orottier
Copy link
Collaborator Author

orottier commented Dec 2, 2023

About the files you deleted in your wtp fork, it wasn't possible to just filter them in the wpt-harness.mjs script?

Yes that would probably be better. My intend is to get rid of the fork soon, but we also have this issue of the missing resource file. I think that needs patching in wpt-runner repo.

For the listener, we agree that the way you did it will break the kind of lazy instantiation we have in the rust side? I do not mean this should be fixed right away if this is the case, but maybe we should create a new issue to fix that

Hum right, this has a large performance impact. I could probably use your help here. Is there a way to lazily return the Listener on request? Also let's move the Listener bindings to a separate PR, right?

@orottier
Copy link
Collaborator Author

orottier commented Dec 6, 2023

New results with webaudio-rs v0.38 en new templating:

  RESULTS:
  - # pass: 3285 (+85)
  - # fail: 1444 (+97)
  - # type error issues: 235 (=)

files ignored: 9 (=)

Previous results #42 (comment)

You may need to run `git submodule sync --recursive`
@orottier
Copy link
Collaborator Author

New results with suspend/resume and AudioListener.setPosition

  RESULTS:
  - # pass: 3386 (+101)
  - # fail: 1380 (-64)
  - # type error issues: 235 (=)

files ignored: 8 (-1)

Previous results #42 (comment)

@orottier orottier marked this pull request as ready for review December 27, 2023 09:13
//
// When any of the positionX, positionY, and positionZ AudioParams for this AudioListener have
// an automation curve set using setValueCurveAtTime() at the time this method is called, a
// NotSupportedError MUST be thrown.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually ok as the error will be thrown by the set_value call. The check is done in the AudioParam.

But this is also something that should be fixed on the rust side at some point because the panic would occur in the render thread which is not good...

@b-ma
Copy link
Collaborator

b-ma commented Dec 27, 2023

Hey, really good job thanks! It's very nice to have such move forward on that point.

I will just add a small fix on AudioParam tomorrow before merging. Then I will refactor the JS code to make it more clean as described in #53, I think it will help to continue on that path more simply

@b-ma
Copy link
Collaborator

b-ma commented Dec 28, 2023

Ok to merge on my side! Good for you?

@orottier
Copy link
Collaborator Author

All good 👍

@b-ma b-ma merged commit b8d668b into main Dec 28, 2023
@b-ma b-ma deleted the feature/wpt-harness branch December 28, 2023 11:13
@orottier
Copy link
Collaborator Author

orottier commented Dec 28, 2023

New results with all audioparam attributes and OfflineAudioContext::state

  RESULTS:
  - # pass: 3413 (+27)
  - # fail: 1353 (-27)
  - # type error issues: 235 (=)

files ignored: 8 (=)

Previous results #42 (comment)

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

Successfully merging this pull request may close these issues.

2 participants