Skip to content

Commit

Permalink
Add performance fix (doesn't abort anymore if reading is too slow)
Browse files Browse the repository at this point in the history
  • Loading branch information
instance01 committed Sep 26, 2018
1 parent fd843d9 commit db2371a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions extension/injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ function getFuncsForInjection () {
);
} else {
return new Promise((resolve, reject) => {
if (performance._now === undefined) {
fixPerformance();
}
resolve({ value: undefined, done: true });
});
}
Expand Down Expand Up @@ -169,13 +172,32 @@ function getFuncsForInjection () {
});
`

var performance = `
// For now the ReadableStream implementation above doesn't support chunks.
// The current code is too slow for Twitch and after a while there can be rare instances where the stream breaks for a few seconds.
// For now just render their performance checks useless, at least until the code above is more performant.
function fixPerformance() {
performance._now = performance.now;
// vc() is used by the wasm worker, let's not break anything here
self.vc = function () {
return performance._now()
};
performance.now = function () {
return 0;
}
}
`

return `
${str2ab}
${fixSeqNr}
${stripAds}
${body}
${filteredArrayBuffer}
${reader}
${performance}
`
}

Expand Down

0 comments on commit db2371a

Please sign in to comment.