-
Notifications
You must be signed in to change notification settings - Fork 20
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
Make AudioWorkletProcessor a class (fixes #24) #25
Make AudioWorkletProcessor a class (fixes #24) #25
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Thanks for the PR! We might need to use a hack here to fall back to a function in older browsers. Currently I think the class will actually end up being transpiled to a function by this project's build script, but I can tweak that. |
Ah, on closer inspection I think this PR is unnecessary... Functions would have a prototype object anyway, so a plain old function should be fine. I saw this error when working from source to implement #26 , but I wasn't being consistent with how you're transpiling your distributed package, so my build chain was leaving this line as-is, which I think results in a named lambda (which has no prototype property) rather than a plain old JS function (which has a prototype property and works just fine). Re-tested on iOS Safari 12. Nothing to do here. |
@hgcummings I also had this problem. I fixed it by making a function and assigning an empty object to its |
@charlieroberts are you referencing the distributed minified version (e.g. from npm) or the raw source (e.g. from GitHub)? I only had this problem with the latter. The issue was the following expression:
The transpiler/bundler used to generate the distributed version of audioworklet-polyfill (microbundle) turns the above expression into a plain-old JS function, which has a prototype property. The transpiler/bundler I was using (rollup) turned the above expression into a lambda function (which doesn't have a prototype property). The above expression is pretty weird-looking to me. I don't recognise it as valid syntax for declaring a function, class, or lambda. Which might explain why different transpilers interpret it differently. My change to explicitly declare a class was unnecessarily disruptive (materially altered the output of microbundle). A change like yours to explicitly declare a function would be safer (wouldn't materially alter the output of microbundle, and should make other transpilers match it more closely), and is probably still worth submitting as a PR. |
Yes, I was using the raw code, and I got this error even without any modifications from my bundler (Browserify). At this point my version is getting kinda far from the polyfill (for example, supporting variable buffer sizes to mimic the |
Yeah, I think that matches what I saw. When I said "my bundler turns this expression into a lambda function" I think actually my bundler wasn't touching this expression at all, and Safari was interpreting it as a lambda declaration. Like I say, I don't recognise it as valid pure ES, at least not in older ES versions, so I'm not surprised it gets interpreted a bit inconsistently. |
Fix for issue #24