WebAudio Node JS wrappers should not be collected if events can be fired
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2019 21:14:12 +0000 (21:14 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 May 2019 21:14:12 +0000 (21:14 +0000)
commit99b3c20f96fbe78e658ebf76e1ad0b63d25a951d
treeeddbf70dd8ec1fda7223590433080c348b36794c
parentf8fc48d265d2a90249ee62ab621c66eb5768de84
WebAudio Node JS wrappers should not be collected if events can be fired
https://bugs.webkit.org/show_bug.cgi?id=197533

Reviewed by Jer Noble.

Source/WebCore:

Before the patch, some web audio nodes could fire event listeners, but were not protected from GC.
Use CustomIsReachable to ensure theses nodes can be collected if:
- their AudioContext is stopped (typically due to document being navigated away).
- their AudioContext is closed.
- nodes do not have event listeners.

Covered by WPT mediacapture-streams/MediaStreamTrack-MediaElement-disabled-audio-is-silence.https.html and
WPT webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
and web audio WebRTC tests.
Specific newly added test: webaudio/webaudio-gc.html

* Modules/webaudio/AudioContext.h:
(WebCore::AudioContext::isClosed const):
* Modules/webaudio/AudioNode.idl:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSAudioNodeCustom.cpp: Added.
(WebCore::JSAudioNodeOwner::isReachableFromOpaqueRoots):

LayoutTests:

* webaudio/webaudio-gc-expected.txt: Added.
* webaudio/webaudio-gc.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/webaudio/webaudio-gc-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/webaudio-gc.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/webaudio/AudioNode.idl
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSAudioNodeCustom.cpp [new file with mode: 0644]