mozilla-b2g/gaia — pull request #25860 by jrburke (2014-11-05 23:32:40+00:00)
Title: Bug 1093398 - [Email] New account page appears again after tapping next

The main issue: in setup_progress there is a race between the this.learnAbout() (called during card construction), which does discovery on the email capabilities, and which can then set this.pushedSecondaryCard to true, and the onCardVisible callback, which is called when the card finally is the card being shown after the 300ms card transition.

If learnAbout completes its discovery within 300ms, which can happen for locally stored autoconfig entries, then when onCardVisible is run, it will look like it was a "cancel" from the previous card.

The root issue is that our card mechanism does not have a good way to remove 2 cards at once. There seems to be an issue with the number of ontransitionend callbacks we get, or our expectations of them, and we get stuck in a case where cards._eatingEventsUntilNextCard is stuck in a true state, effectively disabling the UI.

So I want to fix that, and it would help with some of the goofiness in the current onCurrentVisible callback. that is tracked in bug 973038.

I tried a few experiments without any cards.js change, since that affects all cards:

1) Using the `callingCard` convention of passing the card that generated the current card to the next card, so that the card after setup_progress could call back to setup_progress with a strong signal that a cancel was indeed issued. This was an attempt to remove using onCardVisible as the signal to know if maybe a cancel was triggered.

However, it lead to setup_progress issuing a removeCardAndSuccessors immediately after the next card had also called removeCardAndSuccessors, and while it seemed to work, it made me nervous that I was just playing with async state fire, and that bug 973038 could come into play.

2) I tried using the callingCard approach and just have it call removeCardAndSuccessors specifying 2 cards to remove. This ran afoul of the transitionend issue (the same issue that is the reason for the setTimeout call in onCardVisible.

So I went with the change in this changeset: just serialize the actions so that the card waits for the first onCardVisible to start the learnAbout step. It is the safest, smallest change from existing code, so that it could allow for uplift, and I will use bug 973038 to track the longer term multiple card removal fix.