Fix #311 - Don't write to browser.storage so often

Turns out writing to browser.storage is expensive because state.ts and
config.ts both listen for it in every tab. I'd vaguely assumed that
Firefox would run other tabs as low priority tasks and that this would
not be an issue, but it doesn't.

I also wrote the code in a rush, and while I mused that this potential
risk exists I didn't document it or explore it.

Retrospective: Content switches are expensive - think before you do
anything that may wake many processes and don't make wild assumptions
about how Firefox handles multiprocessing.
This commit is contained in:
Colin Caine 2018-03-07 02:09:41 +00:00
parent 40434455ec
commit 96e32f57e5
2 changed files with 7 additions and 3 deletions

2
package-lock.json generated
View file

@ -9513,7 +9513,7 @@
}
},
"web-ext-types": {
"version": "github:kelseasy/web-ext-types#417d6ddcd76d8a05d7e2222aec3544e01637785b",
"version": "github:kelseasy/web-ext-types#5fa885198a9d43a35dfd0afec64c5ff89338f8a0",
"dev": true
},
"webidl-conversions": {

View file

@ -35,10 +35,14 @@ function *ParserController () {
let keyevent: MsgSafeKeyboardEvent = yield
let keypress = keyevent.key
// TODO: think about if this is robust
// This code was sort of the cause of the most serious bug in Tridactyl
// to date (March 2018).
// https://github.com/cmcaine/tridactyl/issues/311
if (state.mode != "ignore" && state.mode != "hint" && state.mode != "input") {
if (isTextEditable(keyevent.target)) {
state.mode = "insert"
if (state.mode !== 'insert') {
state.mode = "insert"
}
} else if (state.mode === 'insert') {
state.mode = "normal"
}