Does an AudioWorkletNode need to be connected to BaseAudioContext.destination? - javascript

I have an AudioWorkletNode that only takes an input to perform visualization of audio. It outputs nothing, and yet, nothing is happening unless I connect it to BaseAudioContext.destination. This seems silly if it's intentionally designed this way.

I'm assuming you are using Chrome since this is the only browser which supports the AudioWorkletNode so far. In that case it is a known issue. Unless something is connected to the destination Chrome will not process it. The ScriptProcessorNode does for example suffer from the same problem.
I tried to find a tracking bug on bugs.chromium.org but couldn't find one. Therefore I created one: https://bugs.chromium.org/p/chromium/issues/detail?id=1045926
A library that I maintain called standardized-audio-context has a fix for that, although it might be overkill if this is the only workaround you need.

Related

Dojo mysteriously, persistently blanked on page

We use the dojo framework on our websites. A client has called in a panic saying their sales from users of Microsoft Edge have completely dropped off. I've found that in that browser, intermittently, the dojo variable is null after page load. So of course no interaction works for those users, so of course no sales.
But in the course of testing I found this astonishing thing in devtools:
I don't even know how I would do that if I wanted to do it. So I want to track this down but I have no clue what to look for. I might've suspected some weird, recurring setInterval code, but I would not have thought that could get between the two statements on that last console line.
There's a script line just before the </body> tag where I'm able to put a breakpoint. At that point, dojo is set as the framework as expected. So some code that loads after page load is doing it.
(EDIT: I'd be willing to do iterative, brute force breakpoints if I could. But I only have access to Edge via BrowserStack, and trying to set useful breakpoints in minified code is very difficult in Edge's dev tools.)
Does anyone have a suggestion what sort of thing I should look for?
How to debug for this? Is there a client-exposed variable where you can see the functions set to the document's onload, or a way I can put breakpoints in them?
I attempted using a watch() shim in console to watch for the dojo object being changed, but didn't have much luck with that. (but might have done it incorrectly, so if this is an idea, I might need help with proper implementation).
EDIT: There's also this, if this helps make any sense of it. After I delete dojo, setting it works as expected.
Well, I don't know what the specific problem is, but someone has at least given me a way in which this is possible:
window.__defineGetter__('dojo', function(){ return null })
This doesn't exist in the original code, but at least now I see how it's possible at all. The person who gave me this suggests that the code might be trying to get and protect its own copy of dojo, but something about it goes wrong in Edge.

Any alternatives to createScriptProcessor to get live raw audio data?

Firefox seems to have a buggy implementation of this audio node (see this question) so, as I suspect bugs in deprecated features are unlikely to get fixed, I'm looking for another solution.
Mozilla's website says createScriptProcessor is slated to be replaced by audio workers "soon" but work on that doesn't even seem to have begun yet.
All the libs I've looked at seem to use createScriptProcessor. You can get at time domain data from within Analyzer Nodes so that's my next lead but that also seems pretty kludged so I thought I'd ask here in case I've overlooked a better way. Thanks!

Is it possible to trigger Chrome's "Rats! WebGL hit a snag" accidentally?

From what I can tell about this message, it appears when the driver encounters an error. The implication seems to be that the JavaScript code can't trigger this warning even if there's some kind of mistake in it, because of higher-level error checking.
But my code recently triggered it, just once and I haven't been able to reproduce it (and the code — in theory at least — sends the exact same commands to WebGL every time). So I just want to know if I should be debugging my code (I can't see any obvious errors), or if I should put it down to a hardware random / browser bug.
I can post semi-reduced code on request, but it's still about half a thousand lines and I certainly don't expect people to debug it for me, hence the more general is-it-possible question.
I'm struggling a little with what your question means by "trigger". When this error occurs, javascript is always in the causal chain, because WebGL doesn't run without javascript executing it, right? So certainly it's possible to trigger the error accidentally (unless you always trigger it on purpose, which I'm sure is not the case).
However, graphics drivers are notorious for being affected by many factors that are not under programmer control or necessarily detectable by the programmer, and therefore seem non-deterministic. That's why Google recommends that you try reloading the page when the error occurs. (A link to their guidance was here, but they moved or removed the page.) I've often had Chrome successfully display some WebGL after reloading a page, when the previous attempt ended in the "snag" error. (And I know you're aware of that.)
There are certainly times when WebGL code (like the various shaders on http://shadertoy.com/) work fine on some machines and not others, and work fine one minute and not the next, on the same machine. So that suggests that the "snag" error doesn't necessarily imply that your code is at fault.
However, articles like How to write portable WebGL can help you minimize risky practices in your code, and reduce the frequency of these errors.

Simplest way of interactively testing a RESTful service?

I've recently gotten hold of a Rexster server with a REST API and I've been wanting to play around with it in an interactive way. I've never had to work with REST before, most of my work has been around SOAP and .NET. I'm able to trivially perform all of the GET operations just by navigating to the correct URL through the browser and reading the response with JSONView on Firefox, but anything requiring PUT and DELETE appears to require actual code.
Given that I'm still prototyping and testing the API, I'd like to have a way to interactively throw a bunch of requests at it and see what happens. I'm sure I could concoct something in Java or C# fairly fast, but I'm guessing there's a better way (which is why I was thinking javascript above) and was hoping you folks might recommend one.
Please advise, thanks!
If you are trying to debug requests and responses, then Fiddler or HttpScoop is great. However, for just interacting with the API, I've found that the Poster plugin for Firefox is the easiest of all. That sounds like what you're describing.
If you are on Windows, then Fiddler is your best option. I believe the Mac has an equivalent called Charles.
Recent versions of SoapUI allow you to interact with REST interfaces.
Maybe it won't affect you, but there's a bug in the current open source version that causes every query to be executed twice - took me some time to discover while testing a service that returns an incrementing number :-)

Executing JavaScript with Python without X

I want to parse a html-page that unfortunately requires JavaScript to show any content. In order to do so I use a small python-script that pulls the html-code of the page, but after that I have to execute the JavaScript in a DOM-context which seems pretty hard.
To make it even harder I want to use it in a server environment that has no X11-server.
Note: I already read about http://code.google.com/p/pywebkitgtk/ but it seems to need a X-server.
You can simulate a browser environment using EnvJS. However, in order to make use of it, you will have to embed some kind of JavaScript runtime (e.g. Rhino) in your program (or spawn one as an external process).
You could try using Xvfb to have a fake frame buffer, so you won't need to run X11 (though it may be a dependency of Xvfb on your system). Most rendering engines don't have a headless mode, so something like Xvfb is necessary to run them. I used this technique successfully using XULRunner to navigate web pages, though not from python.
I'm still trying to figure this out myself, so take my answer with a grain of salt.
So far, I found http://blog.motane.lu/2009/06/18/pywebkitgtk-execute-javascript-from-python/, which describes the use and the quirks of Pywebkitgtk by someone who has similar needs to what we do.
Later, however, the writer of that blogpost discovered that he can't get it to work with Xvbf, so he hunted some more and found a Qt webkit (possibly in Qt itself, if I understand correctly) http://blog.motane.lu/2009/07/07/downloading-a-pages-content-with-python-and-webkit/. Apparently it's a much better solution than PywebkitGTK.
Naturally, I'll be looking into the other solutions offered here--but I wanted to bring up the Qt solution, because to me, it seems the most likely candidate for what I want to do...and if not, then perhaps it will be for someone else, looking for an answer to this question! :-)
I use VNC or Xvfb for this purpose, combined with Firefox. After experimenting with the two, I settled on XTightVNC. We use it to create screenshots on demand for various test purposes. It's nice to use one of these because you're executing it in an actual browser, same as a user would be (though most users probably won't be using the same OS as your server).
The handy thing about using VNC is that you can connect remotely to set up and test the browser when needed.
This might help: http://code.google.com/p/pyv8/

Categories

Resources