awwx / meteor-offline-data

Meteor offline data project.
MIT License
111 stars 9 forks source link

Slow startup #4

Closed awwx closed 11 years ago

awwx commented 11 years ago

When a window starts up, it checks if it needs to become the agent window or if an agent window is already running. Currently this uses the dead window detection code, which means there's a 4 second delay before a window (such as the first window opened on an application) can become the agent window; which in turn means there's a 4 second delay before any subscriptions can be made or documents downloaded from the server.

The "unload" event is fired when a window is closed. A window can't perform a database transaction in response to the unload event (the event loop for the window is stopped after the event, and so the database transaction callbacks never run), but a window can set items in local storage (which doesn't need callbacks spanning multiple ticks of the event loop).

In response to the "unload" event a window could record in local storage that it has closed. On startup, all windows recorded as closed could be immediately removed from the database. When previous windows had shutdown cleanly, the new window would then be able to become the agent window immediately. Only when a previous window had crashed would the new window need to wait for the dead window detection code.

awwx commented 11 years ago

Fixed in 0.1.0.