farmOS / field-kit

A modular, offline-first companion app to farmOS.
https://farmOS.org
GNU General Public License v3.0
60 stars 39 forks source link

Loading resources from IDB instead of localStorage slows down initial page load #389

Closed jgaehring closed 4 years ago

jgaehring commented 4 years ago

In jgaehring/farmOS-client@146e428 and jgaehring/farmOS-client@fde501e I moved our resources (a.k.a. logTypes) from localStorage to IndexedDB. It seemed like the appropriate thing to do, because we are going to need more and more data stored there, as we will need those resources not just for processing logs but also for assets, areas and taxonomy terms. It seemed like it could slow performance to have a synchronous (that is, blocking) function call to localStorage for such a large amount of data. However, the farmLog utilities are so critical to the app's functionality, particularly how logs get rendered to the screen, that having an asynchronous call sigificantly slows down rendering of the logs themselves. This manifests by seeing the "Let's Get Started!" message displayed on the My Logs screen for about a full second before the cached logs load.

At least, that's how it appears. My suspicion (and hope) is that it's actually not so much about the logs taking longer to load, as the "Let's Get Started!" message taking less time to load; therefore it appearing on the screen for a longer time. I'm really not sure, though, and will have to do more testing to see exactly how the rendering if effected in each scenario.

Regardless, this might just be a performance hit we have to take. It should only effect the initial page load, and I don't see how it will be possible to get around it, seeing how critical those resources are to our core functionality, and they will only become more critical with time.

jgaehring commented 4 years ago

I'm not too concerned with this now, having experienced the app load times more during development. There's some lag to when the logs appear, but the first paint happens relatively quickly at least, and subsequent loading of the My Logs screen, after the app itself has loaded, do not seem to be affected.