GoogleChrome/audion

Allow AudioNodes to be GCed when DevTools is closed.

chihuahua opened this issue · 1 comments

The extension maintains a mapping between node ID (a unique value assigned to each AudioNode) and AudioNode for each web page.
https://github.com/google/audion/blob/795545d1692d11a0348556827622c997dbc9502e/js/entry-points/tracing.js#L108

This means that AudioNodes are never garbage-collected, but we do allow the user to obtain a reference to any AudioNode via the __node__ function. However, when Developer Tools is closed, there should be no reason for the extension to maintain references to AudioNodes.

Today, when the extension's background script receives a web audio update from a tab, it tries to find a connection to a dev tools instance (and such a connection only exists if dev tools is open for that tab):
https://github.com/google/audion/blob/795545d1692d11a0348556827622c997dbc9502e/js/entry-points/background.js#L119

We should add an else block to that logic: If dev tools is closed, we send a MISSING_AUDIO_UPDATES message ...
https://github.com/google/audion/blob/795545d1692d11a0348556827622c997dbc9502e/js/entry-points/background.js#L192

back to the content script of the tab telling the page to drop all references. This message is routed through the content script to code injected within the page itself.
https://github.com/google/audion/blob/795545d1692d11a0348556827622c997dbc9502e/js/entry-points/inject-tracing.js#L30

The injected logic would then handle that message appropriately.
https://github.com/google/audion/blob/795545d1692d11a0348556827622c997dbc9502e/js/entry-points/tracing.js#L1184

Fixed in 0.1.4.