Closed Bug 1128739 Opened 5 years ago Closed 5 years ago

[email] Refactor to streamline startup

Categories

(Firefox OS Graveyard :: Gaia::E-Mail, defect)

x86
macOS
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jrburke, Unassigned)

References

Details

Attachments

(2 files)

The startup pathway in email today could use some streamlining. The mail_app module can be hard to follow given the different async signals that need to be tracked, whether launched via an activity, notification or sync request.

Also, the HTML cache only caches one card, the icon-launched message_list case. Ideally more startup cards could be cached, in a way that would also translate to going to a service worker long term.

The general plan:

* Consolidate async signal listening, for mozSetMessageHandler, in html_cache_restore.js, and wait to know the desired startup card before kickstarting the rest of the loading.

* Use fragment IDs for some activity entry points to speed up decision making on first card, also consult this in html_cache_restore.js.

* See if it is reasonable to cache more than one card, using localStorage instead of the cookie cache. The idea would be to translate that longer term to a service worker cache.

* Reduce the number of async hops for startup. For instance, try to configure the onbadlogin as part of model setup as the model module initializes itself (or BrowserContext, if bug 937959 completes first).

* See if we can get better OOM restoration by using fragment IDs for cards. The system app will relaunch apps with the last fragment ID if it was OOM killed with one. The trick with this is managing the difference between navigation paths that have permutations that differ based on user-selected paths (like if Back could mean two different cards depending on user selected nav flow).

For this last item, be aware that some cards, like manual setup, could have a set of data that should be saved, but not put in fragment IDs. Bug 1125408 has more info.

I have started an experimental branch for this. Due to 2.2 priorities is out of date and incomplete, but filing a link here so I can refer to it later:

https://github.com/jrburke/gaia/tree/fastcache
Duplicate of this bug: 1125408
Note that bug 1126119 tracks making hasPendingMessages not be so slow.  It's possible it will soon return instantly with a value consistent with our needs (because the information will be sent along with our app URL).  I'm xref'ing it so changes to that bug result in notifications for this bug.
See Also: → 1126119
On the "See if it is reasonable to cache more than one card" I should clarify: we already allow caching setup_account_info or message_list, but we only have one cache slot to use, so depending on if the user has set up an account, either one or the other shows up in that one cache slot. The goal is to allow for multiple cache slots.
Comment on attachment 8570125 [details] [review]
[gaia] jrburke:bug1128739-email-startup-refactor > mozilla-b2g:master

Asking Juwei to review the change to setup_account_info. See the pull request for details, specifically just the "No more "set up account?" dialog" section. I am happy to do changes as you likely have some thoughts about it, and we can explore other options if you like.
Attachment #8570125 - Flags: ui-review?(jhuang)
Blocks: 1137510
Comment on attachment 8570125 [details] [review]
[gaia] jrburke:bug1128739-email-startup-refactor > mozilla-b2g:master

As :asuth was nice enough to already give feedback, and I just pushed some changes for the feedback, I shall reward him with a formal r? request. See the pull request for the feedback to the feedback.
Attachment #8570125 - Flags: review?(bugmail)
Attachment #8570124 - Flags: review?(bugmail)
Attachment #8570124 - Flags: review?(bugmail) → review+
Comment on attachment 8570125 [details] [review]
[gaia] jrburke:bug1128739-email-startup-refactor > mozilla-b2g:master

Great cleanup, and thank you very much for the many high quality comments.  Hopefully we never have any more weird startup bugs to investigate again, but if we do, I think the comments will be quite useful!
Attachment #8570125 - Flags: review?(bugmail) → review+
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Juwei, I landed the code on master, since we want to use it as a basis for other refactors, but if you want changes to the UX for the setup_account_info, I will turn those around quickly in a fresh ticket. I will leave ui-review on this ticket to get that feedback, and if need be, spin off a new bug with that feedback.
Blocks: 1138127
Comment on attachment 8570125 [details] [review]
[gaia] jrburke:bug1128739-email-startup-refactor > mozilla-b2g:master

Hi James,
Sorry for the late reply.
It looks reasonable and good to me, thanks.
Attachment #8570125 - Flags: ui-review?(jhuang) → ui-review+
You need to log in before you can comment on or make changes to this bug.