-
Notifications
You must be signed in to change notification settings - Fork 103
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
Running out of hardware contexts when using in iframe(s) in Chrome #34
Comments
Hello! Well this is a limit of AudioContext per domain (see #24 which describes a similar issue in the past, for different reasons) – a singleton is in use to avoid exhausting this limit. But as you are using iframes, thus a different global space for your JavaScript code, we are likely hit this problem as you reach a certain number of iframes. I'd rather use either a SharedWorker, recycle the iframes and/or make the iframes to communicate with their parent window to mitigate the issue. Is it of any help? |
Thanks for the suggestions! Can you tell me what the AudioContext is used for? Is it only for extracting the waveform from the audio file when there is no additional data (.json or .dat) present? |
@benzimmer yes indeed it is used in conjunction with the Web Audio waveform generation but saying this, I feel it creates an AudioContext even if the Web Audio decoding is not used at all. Do you use it? If not, it should not really be a penalty hit on your side. |
No, I don't use it. My main problem here is that the AudioContext is already initialized as soon as the script is loaded and not only when the Context is actually used. But if I see correctly this comes from https://github.com/juliangruber/audio-context/blob/master/index.js#L3 |
Indeed, but it is initialised as soon as waveform-data is required, see waveform-data.js#L7. I will scratch my head a bit to make this lazy loaded. A way to work around this for the time being would be to do this: const WaveformData = require('waveform-data/lib/core');
WaveformData.adapters = require('waveform-data/lib/adapters');
// ... Another possible solution for us would be to build a version of it without the Web Audio builder, especially in case you do not have any build pipeline. |
Hi @benzimmer, #37, #38 and I will close this issue for now but feel free to comment on it later on, and to ask for additional support if the latest release would not really solve your issue. Thanks for your patience :-) |
When the waveform-data.js library is loaded in multiple iframes on the same page the current tab will run out of hardware contexts to spawn new
AudioContext
instances. This seems to be an issue with at least Chrome (latest as of today).embedded-page.html
embedding-page.html
Demo (open dev console): https://jsfiddle.net/r9sv6q9f/
You should see the following error in the console:
The error is produced by this line: https://github.com/bbcrd/waveform-data.js/blob/master/dist/waveform-data.js#L1380
If you need further information please let me know.
The text was updated successfully, but these errors were encountered: