Added a safety thingy that disables autodetection if autodetection consistenly causes lag.

This commit is contained in:
Tamius Han 2018-05-05 23:06:39 +02:00
parent 081f8e968f
commit c35a8c5f59
5 changed files with 23 additions and 5 deletions

View File

@ -1,7 +1,10 @@
# Changelog
### v2.2.5 (AMO, Chrome)
### v2.2.4 (AMO)
Added some anti-lag measures. This seems to be an issue affecting _only_ Chrome (and only then some installs), where canvas.drawImage() won't work properly for some reason.
### v2.2.4
Lots of mostly incredibly minor stuff.
@ -12,7 +15,7 @@ Lots of mostly incredibly minor stuff.
* Fixed some under-the-hood bugs nobody knew they even existed
* A lil bit of refactoring
### v2.2.3 (AMO)
### v2.2.3
* Fixed automatic aspect ratio detection on DRM-protected sites.
@ -20,7 +23,7 @@ Lots of mostly incredibly minor stuff.
* Fixes problems with switching from normal to fullscreen player on youtube. If 2.2.1 didn't fix the font issue, this version should have.
### v2.2.1 (Chrome)
### v2.2.1
* Fixes few chrome-specific fixes/bugs that v2.2.0 introduced. Maybe fixed the font problem.

View File

@ -31,6 +31,7 @@ var _arSetup = function(cwidth, cheight){
console.log("%c[ArDetect::_ard_setup] Starting automatic aspect ratio detection", _ard_console_start);
this._halted = false;
GlobalVars.arDetect.autoDisable.eventCount = 0;
// vstavimo začetne stolpce v _ard_sampleCols.
// let's insert initial columns to _ard_sampleCols
@ -1386,7 +1387,15 @@ function _ard_getTimeout(baseTimeout, startTime){
if( execTime > ExtensionConf.arDetect.autoDisable.maxExecutionTime ){
GlobalVars.arDetect.autoDisable.eventCount++;
if(Debug.debug){
console.log("[ArDetect::_ard_getTimeout] Exec time exceeded maximum allowed execution time. This has now happened" + GlobalVars.arDetect.autoDisable.eventCount + "times in a row.");
}
if(GlobalVars.arDetect.autoDisable.eventCount >= ExtensionConf.arDetect.autoDisable.consecutiveTimeoutCount ){
if (Debug.debug){
console.log("[ArDetect::_ard_getTimeout] Maximum execution time was exceeded too many times. Automatic aspect ratio detection has been disabled.");
}
Comms.sendToBackgroundScript({cmd: 'disable-autoar', reason: 'Automatic aspect ratio detection was taking too much time and has been automatically disabled in order to avoid lag.'});
_ard_stop();
return 999999;

View File

@ -68,6 +68,7 @@ async function _uwbg_onTabSwitched(activeInfo){
// <===[///]----------------------------[\\\]===>
// Check if any frame has a video in it. To enable the popup there only needs to be at least one,
// but the popup controls all frames.
var hasVideos = false;
for(frame of videoFrameList){
hasVideos |= frame.response.hasVideos;
@ -148,6 +149,7 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
config.mode = ExtensionConf.extensionMode;
config.arMode = ExtensionConf.arDetect.mode;
config.arDisabledReason = ExtensionConf.arDetect.disabledReason;
config.arTimerPlaying = ExtensionConf.arDetect.timer_playing;
if(Debug.debug)

View File

@ -176,7 +176,7 @@ function loadConfig(config){
}
document.getElementById("_checkbox_autoArEnabled").checked = config.arMode == "blacklist";
document.getElementById("_autoAr_disabled_reason").textContent = config.arDisabledReason;
document.getElementById("_input_autoAr_frequency").value = parseInt(1000/config.arTimerPlaying);
// process video alignment:

View File

@ -112,6 +112,10 @@
.w24 {
width: 100px;
}
.color_warn {
color: #d6ba4a;
}
.warning {
/*background-*/color: #d6ba4a;
/* color: #000; */
@ -217,7 +221,7 @@
if your browser has been opened for a while.</p><p>Keeping check frequency low will make the problem go away (mostly), but aspect ratio corrections will be delayed a bit.</p></small>
</div> -->
<p><input type="checkbox" id="_checkbox_autoArEnabled" class="_autoAr_enabled _autoAr"> Enable automatic aspect ratio detection?</p>
<p><input type="checkbox" id="_checkbox_autoArEnabled" class="_autoAr_enabled _autoAr"> Enable automatic aspect ratio detection?<br/><small class="color_warn" id="_autoAr_disabled_reason"></small></p>
<p>Checks per second: <input id="_input_autoAr_frequency" class="_autoAr_frequency _autoAr" type="number" min="1" max="999"><span class="button _save_autoAr_frequency _autoAr">Save</span></p>
<div class="warning"><p>NOTE: increasing the frequency can result in <i>very</i> high RAM usage and slow performance.</p></div>