Thursday 20 April 2017

Loading a medium sized JSON file in Electron renderer takes too much time

I am building an app in electron-vue that requires loading a 56MB JSON file (from a third-party that gets updated every few months) on launch but will be used throughout the entire app's life cycle and will be queried a lot by the renderer process(es). The JSON file is stored on disk between each update, so it's only downloaded once every few months.

Loading the file in the main process is pretty fast but loading it in the front-end takes 8-10 seconds! I don't believe this is reasonable for a relatively small file.

I have tried loading the file in main, attaching the resulting object to the main window and retrieving it using remote. This causes the app to just hang. I've looked into IPC but it seems you can't send messages from main to renderer. I've also looked into streaming JSON parsers (Oboe.js), but I don't think it would be a benefit since I really need the top level elements at launch (I can't do anything with nested elements as they are parsed).

Does anyone know of a faster way of loading JSON in the renderer or perhaps a way of sharing the parsed object loaded by main?

Thanks in advance.



via owobeid

No comments:

Post a Comment