You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
[Web] Fix Webkit leak caused by the position reporting audio worklets
Co-authored-by: PizzaLovers007 <trex@parkvue.com>
This commit is contained in:
@@ -635,10 +635,14 @@ class SampleNode {
|
||||
if (this._positionWorklet != null) {
|
||||
return this._positionWorklet;
|
||||
}
|
||||
this._positionWorklet = new AudioWorkletNode(
|
||||
GodotAudio.ctx,
|
||||
'godot-position-reporting-processor'
|
||||
);
|
||||
if (GodotAudio.audioPositionWorkletNodes.length > 0) {
|
||||
this._positionWorklet = GodotAudio.audioPositionWorkletNodes.pop();
|
||||
} else {
|
||||
this._positionWorklet = new AudioWorkletNode(
|
||||
GodotAudio.ctx,
|
||||
'godot-position-reporting-processor'
|
||||
);
|
||||
}
|
||||
this._positionWorklet.port.onmessage = (event) => {
|
||||
switch (event.data['type']) {
|
||||
case 'position':
|
||||
@@ -648,6 +652,7 @@ class SampleNode {
|
||||
// Do nothing.
|
||||
}
|
||||
};
|
||||
this._positionWorklet.port.postMessage('reset');
|
||||
return this._positionWorklet;
|
||||
}
|
||||
|
||||
@@ -678,7 +683,7 @@ class SampleNode {
|
||||
if (this._positionWorklet) {
|
||||
this._positionWorklet.disconnect();
|
||||
this._positionWorklet.port.onmessage = null;
|
||||
this._positionWorklet.port.postMessage({ type: 'ended' });
|
||||
GodotAudio.audioPositionWorkletNodes.push(this._positionWorklet);
|
||||
this._positionWorklet = null;
|
||||
}
|
||||
|
||||
@@ -1198,6 +1203,8 @@ const _GodotAudio = {
|
||||
|
||||
/** @type {Promise} */
|
||||
audioPositionWorkletPromise: null,
|
||||
/** @type {Array<AudioWorkletNode>} */
|
||||
audioPositionWorkletNodes: null,
|
||||
|
||||
/**
|
||||
* Converts linear volume to Db.
|
||||
@@ -1224,6 +1231,7 @@ const _GodotAudio = {
|
||||
GodotAudio.sampleNodes = new Map();
|
||||
GodotAudio.buses = [];
|
||||
GodotAudio.busSolo = null;
|
||||
GodotAudio.audioPositionWorkletNodes = [];
|
||||
|
||||
const opts = {};
|
||||
// If mix_rate is 0, let the browser choose.
|
||||
|
||||
Reference in New Issue
Block a user