Skip to content

Instantly share code, notes, and snippets.

@gregglind
Last active August 23, 2016 15:49
Show Gist options
  • Save gregglind/ef56896ba277733bf15512f3f941e3d5 to your computer and use it in GitHub Desktop.
Save gregglind/ef56896ba277733bf15512f3f941e3d5 to your computer and use it in GitHub Desktop.
Notes on Session Restore, and what feels off

Better UI Feel for session restore

Strategic landscape :

Firefox has been trying to avoid restarting for a long time. With e10s, not-quite-silent updates that may longer be possible. Given that phone apps restart without warning, people may be more used to restarting. Having a better (easier, cleaner, quieter) restart and restore flow might simplify other technical choices.

Thus, is may be in our strategic interest to:

  1. Make restart less painful
  2. Assume restarts / restores happen

UI issues with current restart feel include:

  • multiple windows dance in and out
  • addTab moves things around (jumpy)
  • seems that focus / resize keeps pulling the window to foreground

Should / Desired Feel

  • restore the window with the selected tab first.
  • do all other window restores in the background

Archaeology:

https://hg.mozilla.org/mozilla-central/annotate/24763f58772d45279a935790f732d80851924b46/browser/components/sessionstore/SessionStore.jsm#l3595

    // since resizing/moving a window brings it to the foreground,
    // we might want to re-focus the last focused window
    if (this.windowToFocus) {
      this.windowToFocus.focus();
    }

Snippet for seeing saved state (from a chrome privileged window)

let S = Cu.import("resource:///modules/sessionstore/SessionStore.jsm");
JSON.parse(S.SessionStoreInternal.getBrowserState())

Snippet for adding tabs and such:

var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIWebNavigation)
                       .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                       .rootTreeItem
                       .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIDOMWindow);

mainWindow.gBrowser.addTab()  // can take lots of options, see dxr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment