From 5e25e67e762818f499ee24278c9512b21a191c3e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 4 Apr 2016 08:28:29 +0100 Subject: 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. --- background_scripts/main.coffee | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'background_scripts') 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 = -- cgit v1.2.3