Tone.js icon indicating copy to clipboard operation
Tone.js copied to clipboard

actually close audio context when disposing it

Open marcelblum opened this issue 3 years ago • 3 comments
trafficstars

When looking into #1037 I found that, contrary to the docs, calling context.dispose() does not really close the audio context. Looks like just an oversight. This fixes the following bug:

Tone.getContext().dispose();
// ...
console.log(Tone.getContext().state); // "running", expected "closed"

marcelblum avatar Feb 22 '22 22:02 marcelblum

Codecov Report

Merging #1041 (a8ac712) into dev (1bedd96) will increase coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1041      +/-   ##
==========================================
+ Coverage   98.44%   98.46%   +0.01%     
==========================================
  Files         184      184              
  Lines        7712     7715       +3     
  Branches      678      678              
==========================================
+ Hits         7592     7596       +4     
  Misses         34       34              
+ Partials       86       85       -1     
Impacted Files Coverage Δ
Tone/core/context/Context.ts 98.03% <100.00%> (+0.71%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1bedd96...a8ac712. Read the comment docs.

codecov[bot] avatar Feb 22 '22 22:02 codecov[bot]

oops just noticed this causes some test fails, will look into soon

marcelblum avatar Mar 01 '22 16:03 marcelblum

this should do the trick and also ensure no existing code is broken by this change in case any users were already directly calling context.close() immediately after context.dispose() before the async close process resolves

marcelblum avatar Mar 01 '22 17:03 marcelblum

Thank you @marcelblum for this PR and for all your help in the repo in general! very much appreciated.

tambien avatar Oct 02 '22 14:10 tambien