Bug 95757
Summary: | AudioContext is never destructed. | ||
---|---|---|---|
Product: | WebKit | Reporter: | Pavel Podivilov <podivilov> |
Component: | Web Audio | Assignee: | Kentaro Hara <haraken> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | abarth, crogers, eric.carlson, esprehn, haraken, jer.noble, kbr, michaelbraithwaite |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Pavel Podivilov
I just noticed that V8AudioContext::constructorCallback in V8AudioContextCustom.cpp leaks the pointer to AudioContext.
Shouldn't it also call V8DOMWrapper::setJSWrapperForActiveDOMObject to deref AudioContext in JS wrapper weak callback? Looks like currently all AudioContexts live forever.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Kentaro Hara
I'll take a look.
Pavel Podivilov
There is another problem with this code. After fixing the leak, you'll get debug crash in AudioContext::uninitialize.
Here is why. ScriptExecutionContext::stopActiveDOMObjects is called twice on navigation, first time from Document::detach and then from FrameLoader. As a result AudioContext::stop is also called twice.
First AudioContext::uninitialize deletes the AudioContext object. Then AudioContext::uninitialize is called again, but AudioContext is already destructed.
michaelbraithwaite
Would this explain why we hit the exception "audio resources unavailable for AudioContext construction" so often? The 4 AudioContext limit gets exhausted even though at most one is currently active. I assumed there is no guarantee the unused ones will be garbage collected in any event.
As this is in V8*.cpp is this only in Chrome? Safari hits the same issue.
If it is a separate issue I'll bug it, though I think in part its a spec issue with the lack of 'destroy' method on the JavaScript AudioContext. If it is a finite resource and given when gc gets invoked is not controllable from JavaScript it means sometimes it fails which means users get no audio (or an broken app). For a single page web app where multiple 'apps' run on it the life time model doesn't seem great. You can see this on https://turbulenz.com/ if you keep reloading some of the games.
Chris Rogers
The AudioContext releases its resources in AudioContext::uninitialize(), not in the destructor, so delayed garbage collection is not likely to be the issue.
Michael, I'll have a look at your case...
Chris Rogers
I believe this was fixed in:
http://trac.webkit.org/changeset/135152