aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-04-04 08:28:29 +0100
committerStephen Blott2016-04-04 08:32:28 +0100
commit5e25e67e762818f499ee24278c9512b21a191c3e (patch)
tree7abdec84efa784dee97a14acd14afad820a52ccd /background_scripts
parent52fc561350becabd8ba554159f01e7186c78aa09 (diff)
downloadvimium-5e25e67e762818f499ee24278c9512b21a191c3e.tar.bz2
Add backstop for global link hints.
This is not at all satisfactory. I've seen cases where global link hints hangs, apparently because we do not hear back from a frame. The issue is repeatable when it happens, but not repeatable in general (if you reload the page, then it goes away). This suggests that there may be something fundamentally wrong with the global link-hints logic. However, what? In the interim, this adds a timer to trigger link-hints mode activation with whataver hints we do have after a short period of time. Ideally, we'll be able to get rid of this soon.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee20
1 files changed, 14 insertions, 6 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index ab7e881a..1d69cf3f 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -367,7 +367,7 @@ HintCoordinator =
delete @tabState[tabId].ports[frameId]
# It could be that we're expecting hints from this frame; schedule "sending" dummy/empty hints instead.
Utils.nextTick =>
- @postHintDescriptors tabId, frameId, {hintDescriptors: []} if frameId in tabState[tabId].frameIds
+ @postHintDescriptors tabId, frameId, hintDescriptors: []
# We can delete the tab state when we see an "exit" message, that's the last message in the sequence.
delete @tabState[tabId] if messageType == "exit"
@@ -377,14 +377,22 @@ HintCoordinator =
@tabState[tabId] = {frameIds: frameIdsForTab[tabId][..], hintDescriptors: [], originatingFrameId, modeIndex}
@tabState[tabId].ports = extend {}, portsForTab[tabId]
@sendMessage "getHintDescriptors", tabId, {modeIndex}
+ # FIXME(smblott) This should not be necessary; it's a backstop to mitigate against the possibility that,
+ # for some reason, we do not hear back from a frame.
+ unless @debug
+ for frameId in frameIdsForTab[tabId]
+ do (frameId) =>
+ Utils.setTimeout 400, =>
+ @postHintDescriptors tabId, frameId, hintDescriptors: []
# Receive hint descriptors from all frames and activate link-hints mode when we have them all.
postHintDescriptors: (tabId, frameId, {hintDescriptors}) ->
- @tabState[tabId].hintDescriptors.push hintDescriptors...
- @tabState[tabId].frameIds = @tabState[tabId].frameIds.filter (fId) -> fId != frameId
- console.log "postHintDescriptors", tabId, frameId, "[#{@tabState[tabId].frameIds.length}]" if @debug
- if @tabState[tabId].frameIds.length == 0
- @sendMessage "activateMode", tabId, @tabState[tabId]
+ if frameId in @tabState[tabId].frameIds
+ @tabState[tabId].hintDescriptors.push hintDescriptors...
+ @tabState[tabId].frameIds = @tabState[tabId].frameIds.filter (fId) -> fId != frameId
+ console.log "postHintDescriptors", tabId, frameId, "[#{@tabState[tabId].frameIds.length}]" if @debug
+ if @tabState[tabId].frameIds.length == 0
+ @sendMessage "activateMode", tabId, @tabState[tabId]
# Port handler mapping
portHandlers =