Electron app slow to start first time runnning - electron

I've an electron app the start time of which is very slow - 20-30 seconds - when it runs for the first time after packaging. Subsequent times it's run the start time is 1, 2 seconds. Either; are there any thoughts on why this might happen or; are there any tools available that I might use to track the source of this.
macOS

Electron uses Chromium (Used By Google Chrome), maybe that's why when your application starts for the first time it takes time to make cache and other stuff, it also depends from Computer to Computer.
Some of the reason i've listed from the articles below.
Modules
for example you wanted to do some stuff but you are lazy and search for a module on which can do the work for you, i have no problem with that but sometimes modules have their own dependencies and those dependencies might have their own dependencies these dependencies can effect your start up time as "require" or "import" will load everything up which can cause your code be very big than it would've been if you wrote it yourself or downloaded a optimized small library to do same thing.
Using Synchronous Code
see i personally don't like the promise tree (the list of .then for handling asynchronous code) but if i use await or something it probably block my main process which can cause my application to freeze, that's why it's preferred to use promises.
Using Old APIs
In modern versions of chromium there might be better APIs for handling stuff which might be slow if you used old APIs.
Over all you don't need to worry if you're code will work on other browsers or not (until you're also making a web version of that too), because latest electron version will introduce latest APIs which will be shipped to your end users so don't worry if your code will work or not.
You Can Read These Articles Below Which may help you to increase your applications Performance:
How to make your Electron app faster - DEV.TO
Performance - ELECTRONJS.ORG
Why are desktop apps made with electron js framework slow? - QUORA

Related

How can one respond to a Hot Reload?

I have a long-lived object in my Dart app, created using the output of several computationally expensive functions. Often, I change these expensive functions - but because their output is cached, I cannot see the results of my changes without restarting the app.
Is there a way (perhaps using a Dart VM API) to respond to a Hot Reload and recreate my object accordingly?
Note: I am looking for a solution that does not depend on the Flutter framework, as the relevant code is in a standalone Dart package.

Frequently refreshing web page during long-running process

I've been hunting around my issue for a while, probably the best I've come up with is another Stack Overflow question: How should I perform a long-running task in ASP.NET 4?
I'm in a similar place in that I'm wanting to understand what my options are, but I don't feel I know enough specifically about MVC to come to a view. I'm using MVC 5 but with the 4.8 framework, plus I note that technologies such as SignalR have become available since this question was asked. I was wondering if any experienced MVC'ers could give me a view?
I too have a long running process. More specifically, the user is importing a file. The file is delimited so the import happens line by line. The file might be thousands of lines long. Each line will be parsed and imported in a fraction of a second but the whole operation might take several minutes.
I don't particularly need behaviour to be asynchronous, but because of the length of the entire process I want to regularly update the user on progress. I'm wondering what options I have?
I've got a vague recollection that I might have looked at this problem 20-odd years ago (Classic ASP), and solved it by regular flushes, sending a bit more of the page to the client every few seconds, but I'm trying also to use a _Layout page now, so I've sent the page back already. So I don't think I have that option, even assuming such a mechanism still exists. A bit more recently, but still a while ago, I might have used javascript to poll but everything I'm reading now seems to point me to newer technologies which I'm not sure I fully understand yet.
I'm just wondering how would you solve this problem?
I would not be performing any of the file parsing on the web server, especially if it's thousands of rows long. I would delegate this to a background service of sorts, whether that be a Lambda service in the cloud or a Windows service or a scheduled task. You could then call your SignalR hub from the background task (whatever that might be) to update the progress of the import.

React Native - Improve cold start time

The project I was working is to use react native to create an iOS app.
Following is the cold start time in iPhone 5S release build
Pre-main time: 0.52 seconds
App did launch to javascript did load time: 2.12 seconds
JS render time: 0.74 seconds
Total time: 3.34 seconds
The slowest part is to wait react library to load the js bundle (2.2MB). Is the loading time looks normal? How can I improve the js bundle loading time? Thanks so much.
Reducing the js bundle size can improve the time from Application did launch to javascript did load. For a new Hello World project, it only took 0.18-0.19 seconds (iPhone 5S).
Yes, the problem that you described really exist. As a possible solution you can use ram-bundle format, that metro bundler provides.
In this case you will not load the entire js-bundle - you will load only part, that you need at a startup (in a lot of application are a lot of places, which user may not even see, and this feature allow you load such parts, only when they are required). So you can simplify your entry point and load only small piece of your bundle.
You can look at react-native-bundle-splitter. This library well integrated with almost all popular navigation libraries and allows you to postpone a loading of specific routes. For example, if you have a login screen, you can load at start up only this screen, and all others load in background or start the loading of them, only when user can see them. And the startup time of your complex application will be almost equally as for "Hello world" application.
Whether the time ok is up to you and your app users only =)
Obviously, if reducing the js bundle size improves the time, you should do your best to get it done. There is several steps I guess can help you:
first of all, DRY: doubling code do increase the size
check for using npm packages, remove unused (also as unused inner modules)
obfuscate and minify the bundle with third-party tools
Also it should be done to reduce initializing complexity
check an asymptotic complexity of your algorithms - is can cause to time increasing
remove unused variables, functions and data - it can be a reason of redundant memory usage
And I can just advice you also try to affect not only an actual time but also a time feeling. For example, use an animated splash screen

iOS- UIWebView and downloaded code

I know that Apple's terms for apps disallows downloading and executing code, but there seems to be an exception for JavaScript running in a UIWebView:
3.3.2 An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework.
Does this mean that I can download and execute interpreted code, as long as it runs in a UIWebView?
I am developing an MMO, for which I would like to allow mods. It would have clients for iOS, Android, browsers, and eventually native desktop clients. I would do it entirely in the browser, but iOS doesn't support WebGL.
Is there a way to do this without violating the license agreement? I would really like to see a full-featured version on iPad, and I would be willing to put these mods in the app store so they can be reviewed, if that's possible.
These mods would be pretty simple, but more complicated than a data file could offer.
Yes. You simply download the Javascript and put it inside script tags using a UIWebView's loadHTMLString:baseURL: method, and then getting the result of various function calls using stringByEvaulatingJavaScriptFromString: method. You'd have to define an API where your game would query specific functions in your addon, but that should be pretty easy.
In fact, you may not even need to put the UIWebView in a view anywhere - you could simply instantiate a UIWebView*, load the javascript, and make the calls.
You are correct that downloading and interpreting Javascript is acceptable.
The Facebook and Gmail apps, as well as countless others, do this.

Self Updating

What's the best way to terminate a program and then run additional code from the program that's being terminated? For example, what would be the best way for a program to self update itself?
You have a couple options:
You could use another application .exe to do the auto update. This is probably the best method.
You can also rename a program's exe while it is running. Hence allowing you to get the file from some update server and replace it. On the program's next startup it will be using the new .exe. You can then delete the renamed file on startup.
It'd be really helpful to know what language we're talking about here. I'm sure I could give you some really great tips for doing this in PowerBuilder or Cobol, but that might not really be what you're after! If you're talking Java however, then you could use a shut down hook - works great for me.
Another thing to consider is that most of the "major" apps I've been using (FileZilla, Paint.NET, etc.), are having the updaters uninstall the previous version of the app and then doing a fresh install of the new version of the application.
I understand this won't work for really large applications, but this does seem to be a "preferred" process for the small to medium size applications.
I don't know of a way to do it without a second program that the primary program launches prior to shutting down. Program 2 downloads and installs the changes and then relaunches the primary program.
We did something like this in our previous app. We captured the termination of the program (in .NET 2.0) from either the X or the close button, and then kicked off a background update process that the user didn't see. It would check the server (client-server app) for an update, and if there was one available, it would download in the background using BITS. Then the next time the application opened, it would realize that there was a new version (we set a flag) and popped up a message alerting the user to the new version, and a button to click if they wanted to view the new features added to this version.
It makes it easier if you have a secondary app that runs to do the updates. You would execute the "updater" app, and then inside of it wait for the other process to exit. If you need access to the regular apps DLLs and such but they also need updating, you can run the updater from a secondary location with already updated DLLs so that they are not in use in the original location.
If you're using writing a .NET application, you might consider using ClickOnce. If you need quite a bit of customization, you might look elsewhere.
We have an external process that performs updating for us. When it finds an update, it downloads it to a secondary folder and then waits for the main application to exit. On exit, it replaces all of the current files. The primary process just kicks the update process off every 4 hours. Because the update process will wait for the exit of the primary app, the primary app doesn't have to do any special processing other than start the update application.
This is a side issue, but if you're considering writing your own update process, I would encourage you to look into using compression of some sort to (1) save on download and (2) provide one file to pull from an update server.
Hope that makes sense!

Resources