Skip to content

Fix regression with discard behavior for new window creation#23

Open
echuber2 wants to merge 1 commit intoJman:masterfrom
echuber2:pr-20251124
Open

Fix regression with discard behavior for new window creation#23
echuber2 wants to merge 1 commit intoJman:masterfrom
echuber2:pr-20251124

Conversation

@echuber2
Copy link

Fixes #22
Fixes #19

There was a regression with #20 because tearing off a tab fires the window creation event, which would cause all tabs to be discarded. This would also happen if a new window was opened with a hotkey or from the menu.

The PR attempts a different solution for #19 although in that case, the user needs to click Chrome's popup button to restore within the 7-second delay period (before the extension discards all tabs with the startup action).

These are the notes I wrote in the commit message:

  • For the windows.onCreated handler, discard only the specific window that was created.
    • This is more efficient because it does not loop over all windows each time a new window is created.
    • Opening a new window or tearing off a tab will no longer discard the tabs in all other windows.
  • Put a 7-second delay on startup discard of all tabs in all windows.
    • This helps to ensure that all inactive tabs are discarded soon after startup, because sometimes the browser tries to reawaken some of the previously-discarded tabs after the browser loads.
    • When a session is restored at startup after a crash, Chrome replaces the tabs in the current window (while it might also create new windows if multiple windows were previously open), so this delayed discard of all tabs can handle the existing window. The session restore option must be clicked within 7 seconds of opening the browser.

- For the windows.onCreated handler, discard only the specific
  window that was created.
  - This is more efficient because it does not loop over all windows
    each time a new window is created.
  - Opening a new window or tearing off a tab will no longer discard
    the tabs in all other windows.
- Put a 7-second delay on startup discard of all tabs in all windows.
  - This helps to ensure that all inactive tabs are discarded soon
    after startup, because sometimes the browser tries to reawaken
    some of the previously-discarded tabs after the browser loads.
  - When a session is restored at startup after a crash, Chrome
    replaces the tabs in the current window (while it might also
    create new windows if multiple windows were previously open), so
    this delayed discard of all tabs can handle the existing window.
    The session restore option must be clicked within 7 seconds of
    opening the browser.
@echuber2
Copy link
Author

I'll note that you can test the session restore behavior by forcing Chrome to crash. Put this special URL in the location bar: chrome://inducebrowsercrashforrealz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discards all tabs when a tab is dragged out of this windowall tabs Doesn't work well at Restoring Tabs after browser hangs

1 participant