Put Tinter loop body in a try/catch

So whatever other random ways this process fails in don't cause it
to take out the whole app.
pull/21833/head
David Baker 2018-04-11 18:31:54 +01:00
parent 5f2d9b6c54
commit 760f21b1d9
1 changed files with 52 additions and 44 deletions

View File

@ -298,6 +298,7 @@ class Tinter {
for (let i = 0; i < document.styleSheets.length; i++) {
const ss = document.styleSheets[i];
try {
if (!ss) continue; // well done safari >:(
// Chromium apparently sometimes returns null here; unsure why.
// see $14534907369972FRXBx:matrix.org in HQ
@ -351,6 +352,13 @@ class Tinter {
}
}
}
} catch (e) {
// Catch any random exceptions that happen here: all sorts of things can go
// wrong with this (nulls, SecurityErrors) and mostly it's for other
// stylesheets that we don't want to proces anyway. We should not propagate an
// exception out since this will cause the app to fail to start.
console.log("Failed to calculate CSS fixups for a stylesheet: " + ss.href, e);
}
}
if (DEBUG) {
console.log("calcCssFixups end (" +