Skip to content

Commit

Permalink
check for the active frame before updating tabPage
Browse files Browse the repository at this point in the history
race condition was updating tabPage without an active frame leading to browser freeze

Auditors: @bbondy

fix brave#11028

sibling commits:
- 0.20.x d738190
- 0.19.x 1301ad9
  • Loading branch information
cezaraugusto authored and syuan100 committed Nov 9, 2017
1 parent a38e2ef commit 2c8239b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/renderer/reducers/frameReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ const frameReducer = (state, action, immutableAction) => {
state = frameStateUtil.updateFramesInternalIndex(state, Math.min(sourceFrameIndex, index))
state = frameStateUtil.moveFrame(state, tabId, index)

// Update tab page index to the active tab in case the active tab changed
const activeFrame = frameStateUtil.getActiveFrame(state)
state = frameStateUtil.updateTabPageIndex(state, activeFrame.get('tabId'))
// avoid the race-condition of updating the tabPage
// while active frame is not yet defined
if (activeFrame) {
// Update tab page index to the active tab in case the active tab changed
state = frameStateUtil.updateTabPageIndex(state, activeFrame.get('tabId'))
}
state = frameStateUtil.setPreviewFrameKey(state, null)
}

Expand Down

0 comments on commit 2c8239b

Please sign in to comment.