Skip to content

Commit

Permalink
WebWorker兼容新版Chrome83:在file协议下如果立即revokeObjectURL,WebWorker将无法正常使用
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Jun 23, 2020
1 parent bb4914a commit 6a5ea79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/extensions/sonic.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/extensions/sonic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,9 @@ SonicFunction.Async=function(set){
var url=(window.URL||webkitURL).createObjectURL(new Blob(["var wk_sonic=(",sonicCode,jsCode], {type:"text/javascript"}));

worker=new Worker(url);
(window.URL||webkitURL).revokeObjectURL(url);//必须要释放,不然每次调用内存都明显泄露内存
setTimeout(function(){
(window.URL||webkitURL).revokeObjectURL(url);//必须要释放,不然每次调用内存都明显泄露内存
},10000);//chrome 83 file协议下如果直接释放,将会使WebWorker无法启动

worker.onmessage=function(e){
var ctx=openList[e.data.id];
Expand Down

0 comments on commit 6a5ea79

Please sign in to comment.