Mailspring/internal_packages
Evan Morikawa e90735ed6e feat(win): faster popout windows
Summary:
This diff is designed to dramatically speed up new window load time for
all window types and reduce memory consumption of our hot windows.

Before this diff, windows loaded in ~3 seconds. They now boot in a couple
hundred milliseconds without requiring to keep hot windows around for
each and every type of popout window we want to load quickly.

One of the largest bottlenecks was the `require`ing and initializing of
everything in `NylasExports`.

I changed `NylasExports` to be entirely lazily-loaded. Drafts and tasks
now register their constructors with a `StoreRegistry` and the
`TaskRegistry`. This lets us explicitly choose a time to activate these
stores in the window initalization instead of whenever nylas-exports
happens to be required first.

Before, NylasExports was required first when components were first
rendering. This made initial render extremely slow and made the proposed
time picker popout slow.

By moving require into the very initial window boot, we can create a new
scheme of hot windows that are "half loaded". All of the expensive
require-ing and store initialization is done. All we need to do is
activate the packages for just the one window.

This means that the hot window scheme needs to fundamentally change from
have fully pre-loaded windows, to having half-loaded empty hot windows
that can get their window props overridden again.

This led to a major refactor of the WindowManager to support this new
window scheme.

Along the way the API of WindowManager was significantly simplifed.
Instead of a bunch of special-cased windows, there are now consistent
interfaces to get and `ensure` windows are created and displayed. This
DRYed up a lot of repeated logic around showing or creating core windows.

This also allowed the consolidation of the core window configurations into
one place for much easier reasoning about what's getting booted up.

When a hot window goes "live" and gets populated, we simply change the
`windowType`. This now re-triggers the loading of all of the packages for
the window. All of the loading time is now just for the packages that
window requires since core Nylas is there thanks to the hot window
mechanism.

Unfortunately loading all of the packages for the composer was still
unnaceptably slow. The major issue was that all of the composer plugins
were taking a long time to process and initialize. The solution was to
have the main composer load first, then trigger another window load
settings change to change the `windowType` that loads in all of the
plugins.

Another major bottleneck was the `RetinaImg` name lookup on disk. This
requires traversing the entire static folder synchronously on boot. This
is now done once when the main window loads and saved in a cache in the
browser process. Any secondary windows simply ask the backend for this
cache and save the filesystem access time.

The Paper Doc below is the current set of manual tests I'm doing to make
sure no window interactions (there are a lot of them!) regressed.

Test Plan: https://paper.dropbox.com/doc/Window-Refactor-UYsgvjgdXgVlTw8nXTr9h

Reviewers: juan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2916
2016-04-22 13:30:42 -07:00
..
account-sidebar feat(unread/spam): New items in the sidebar for unread and spam 2016-04-19 11:32:33 -07:00
attachments fix(styles): Fix styles for attachment and upload items 2016-03-23 17:16:25 -07:00
category-picker fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView 2016-04-04 15:22:01 -07:00
composer feat(win): faster popout windows 2016-04-22 13:30:42 -07:00
composer-emoji fix(composer-emoji): Fix calculation for category positioning 2016-04-12 14:51:56 -07:00
composer-scheduler feat(win): faster popout windows 2016-04-22 13:30:42 -07:00
composer-signature 🎨(preferences): Adjust textbox styles for signatures and templates 2016-04-07 14:12:35 -07:00
composer-spellcheck fix(syncback): Bidirectional transforms, ready-to-send saved state 2016-03-16 19:27:12 -07:00
composer-templates refactor(composer): Make session, draft available everywhere 2016-04-19 16:05:15 -07:00
composer-translate refactor(composer): Make session, draft available everywhere 2016-04-19 16:05:15 -07:00
draft-list fix(draft-list): Select proper sheet when launching in drafts perspective 2016-04-21 16:00:06 -07:00
events bump(electron): 0.36.7 => 0.37.5 2016-04-12 18:42:57 -07:00
github-contact-card lint(github-card): Change duplicated variable name 2016-04-19 17:34:19 -07:00
link-tracking refactor(composer): Make session, draft available everywhere 2016-04-19 16:05:15 -07:00
message-autoload-images fix(autoload-images): Bar disappears when you choose to load images 2016-03-07 18:19:17 -08:00
message-list fix(attachments): Don't show the paperclip for inline attachments < 3k (signatures, etc.) 2016-04-20 10:44:32 -07:00
message-view-on-github fix(view-on-github): Add readme and fix bug 2016-04-14 17:03:57 -04:00
mode-switch 💄(sidebar): Replace icon with person 2016-03-10 11:15:52 -08:00
notification-mailto
notification-update-available fix(require): Move more requires to new electron format 2016-04-13 15:35:01 -07:00
notifications fix(db): Counts no longer require Thread table join 2016-04-11 13:51:31 -07:00
onboarding feat(win): faster popout windows 2016-04-22 13:30:42 -07:00
open-tracking refactor(composer): Make session, draft available everywhere 2016-04-19 16:05:15 -07:00
participant-profile fix(related-threads): Show snippet in addition to subject #1683 2016-04-14 17:33:43 -04:00
personal-level-indicators es6(*): convert 20+ source files used in example packages to ES2016 2016-02-29 18:47:22 -08:00
phishing-detection Fixed text overflow in phishing detection indicator 2016-03-11 20:33:06 +01:00
plugins 🎨(preferences): Change spacing and button sizes 2016-04-07 14:32:51 -07:00
preferences feat(preferences): Add theme picker button to Appearances 2016-04-19 17:14:25 -07:00
print 💄(print): Fix #1425 2016-02-26 14:40:16 -08:00
screenshot-mode feat(screenshot-mode): Minor fix to unmount method 2016-01-29 16:59:51 -08:00
send-and-archive fix(gmail-labels): Constraint so threads always belong to all,spam or trash 2016-03-10 14:13:31 -08:00
send-later refactor(composer): Make session, draft available everywhere 2016-04-19 16:05:15 -07:00
sidebar-fullcontact bump(react): 0.13.2 => 0.14.7 2016-03-29 01:43:12 -07:00
system-tray fix(tray): Re add old icon assets for tray icon for win32 and linux 2016-03-25 10:05:17 -07:00
theme-picker feat(preferences): Add theme picker button to Appearances 2016-04-19 17:14:25 -07:00
thread-list fix(attachments): Don't show the paperclip for inline attachments < 3k (signatures, etc.) 2016-04-20 10:44:32 -07:00
thread-search feat(unread/spam): New items in the sidebar for unread and spam 2016-04-19 11:32:33 -07:00
thread-search-index feat(thread-search): Make thread search indexing smarter 2016-04-07 09:57:29 -07:00
thread-snooze fix(focus): Remove focusedField in favor of imperative focus, break apart ComposerView 2016-04-04 15:22:01 -07:00
ui-dark refactor(ui-variables): Clean UI variables for consistency/usage 2016-03-15 11:18:50 -07:00
ui-darkside correcting size of window contol buttons 2016-04-02 15:02:26 -05:00
ui-light
ui-taiga 🎨(themes): Tweak Taiga to feel more native 2016-03-27 15:51:27 -07:00
ui-ubuntu refactor(ui-variables): Clean UI variables for consistency/usage 2016-03-15 11:18:50 -07:00
undo-redo bump(react): 0.13.2 => 0.14.7 2016-03-29 01:43:12 -07:00
unread-notifications Revert "fix(sidebar): Correctly update sidebar when a notif is selected" 2016-02-02 10:58:24 -08:00
worker-sync feat(win): faster popout windows 2016-04-22 13:30:42 -07:00
worker-ui fix(require): Move more requires to new electron format 2016-04-13 15:35:01 -07:00