Page MenuHomePhabricator

Quicksand fails to navigate back to page 0 on Chrome, Firefox sporadically
Closed, ResolvedPublic

Description

To reproduce near 100% for btrahan, using Chrome or Firefox:

EXPECTED - end up back on /p/btrahan/
ACTUAL - stay on /feed/

Doing some debugging in the past, page id has been "2" in this case, where it should be 0.

Event Timeline

btrahan claimed this task.
btrahan raised the priority of this task from to Normal.
btrahan updated the task description. (Show Details)
btrahan added a project: Quicksand.
btrahan moved this task to Backlog on the Quicksand board.
btrahan added a parent task: T7573: Ship Quicksand.
btrahan added a subscriber: btrahan.

Made a small modification to JX.History.install() to get some debugging information that is VERY interesting... Its at the very bottom.

install : function(mechanism) {
  if (__DEV__) {
    if (JX.History._installed) {
      JX.$E('JX.History.install(): can only install once.');
    }
    JX.History._installed = true;
  }

  mechanism = mechanism || JX.History.DEFAULT;

  if (mechanism >= JX.History.PUSHSTATE && 'pushState' in history) {
    JX.History._mechanism = JX.History.PUSHSTATE;
    JX.History._initialPath = JX.History._getBasePath(location.href);
    JX.Stratcom.listen('popstate', null, JX.History._handleChange);
  } else if (mechanism >= JX.History.HASHCHANGE &&
             'onhashchange' in window) {
    JX.History._mechanism = JX.History.HASHCHANGE;
    JX.Stratcom.listen('hashchange', null, JX.History._handleChange);
  } else {
    JX.History._mechanism = JX.History.POLLING;
    setInterval(JX.History._handleChange, 200);
  }
  console.log(JX.History._mechanism);
  console.log(history.state);
},

For Chrome, Firefox, and now even Safari, the value of history.state is sometimes set to an object like { 'quicksand' : 1 }. The mechanism is always PUSHSTATE.

On /p/<username>/, I am getting the following consistently

Safari: { quicksand : 1 }
Chrome: { quicksand : 1 }
Firefox: { quicksand : 3 }

On /, I am getting the following consistently

Safari: { quicksand : 2 }
Chrome: { quicksand : 2 }
Firefox: { quicksand : 1 }

Anyway, just a dump of where I am at on this mystery.

...meant to 'cc' you in case my last comment sparks any debugging juices...

Oh, okay, here's a big break through, at least on reproduction steps.

  • open up a new tab in any of these browsers.
  • visit phabricator instance home page
    • console.log(history.state); in install will show null
  • visit another page
    • console.log(data); in quicksand _onchange event will show {quicksand : 1}
  • visit phabricator instance home page again
    • console.log(data); in quicksand _onchange event will show {quicksand : 2}
  • reload the page
    • console.log(history.state); in install will show {quicksand : 2}

Things seem to work okay until you reload the page.

If browsers are carrying state across reloads, maybe we just need to initialize JX.Quicksand.id to window.history.state || 0 (and throw away that object patch).