I'm developing an electron application and the thing I don't understand is how apps like visual studio code achieve so fast startup times, by that I mean the time between clicking the icon until a window opens (until main.js gets loaded).
I already read many articles about speeding up electron but they all just talk about the stuff that happens AFTER main.js is loaded.
I downloaded the electron-quick-start example and packaged it using electron-builder as portable app.
Visual Studio Code: 1-2 secs until a window shows up
electron-quick-start: 5-10 secs
I was just wondering where the performance issue is, portable? electron-builder?
I found an issue in electron-builder that seems to indicate, that portable apps are extracted into a temp folder on app start, thats whats slow
Just to close this question:
Problem:
As indicated in the comments, the problem really is the portable mode of electron-builder. Portable Apps first unpack themselves into a temporary folder on your computer which can be a cpu intensive task because of compression.
Only after the app files have been unpacked, the main.js is actually loaded by node / electron.
Solutions:
Use an installer
When using an installer, the unpacking is done during installation of course, and not every time the app is started.
Use a splashimage (untested)
Although it is nowhere mentioned in the electron-builder docs, the code seems to indicate that you can set a splashImage bmp option:
https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/targets/nsis/nsisOptions.ts
/**
* The image to show while the portable executable is extracting. This image must be a bitmap (`.bmp`) image.
*/
readonly splashImage?: string | null
That would at least make it clear something is happening, instead of the user clicking the icon multiple times because the app doesn't open
Related
As well as a UI, I'd like users to have the option of passing in command line options to my tool and for it to output the response to the command line (eg manually or in cron).
Even without creating a window, the UI gets going (eg taskbar on the mac), and on a linux back-end server with no UI libraries it crashes completely.
Is there a way I can avoid having to ship two apps separately, and also more annoyingly using electron to package up one exe, and something like pkg for the other?
Thanks!
You can use a bundling tool like EncloseJS to wrap your Electron application. This would allow you to write a CLI interface. You would then need to move the code that does the actual work to a shared library that both Electron and your CLI can use. You could then introduce a --headless flag that would simply not start the Electron app, while omitting the flag would start the app as usual.
We are about to start a new project which should be like a desktop app but still run inside a browser for creating items in a system. After these items are created, an .EXE file on the LOCAL machine must be called to do some code generation. Is this possible if using Angular to develop the application or do we need third party libs for executing local .exe's?
No, this is not possible out of the box. Browsers make very sure that local executables cannot be started. You would have to look for other solutions.
One possible idea, depending on how much effort you want to invest, would be to compile the WebKit engine yourself, i.e., create a binary "wrapper" which runs the browser engine itself. Then you are free to extend it in whatever fashion you need, including adding the possibility to start local .exe's (or if those .exe's are your own applications, you could compile them right into your WebKit wrapper).
My current App (WPF in Visual Studio) weighs 2MB.
And now I want to re-create this App with Node and Javascript.
Why? Primary reason is - I want to learn some Javascript (yes, this is My way to learning and please dont give me advices how to learn JS). Secondary reason - I want to use full power of CSS3, while WPF App supports only CSS2.
The problem is Weight. Any example App builded with Electron or NWJS weighs about 115MB!!!
I can understand that Desktop App require Node and Browser to work, but 115MB?!
So my question is - Is there any way to create Lightweight Desktop App with Electron/NWJS (or similar alternative)?
I can accept final weight about 50-60MB.
Electron or NW.js are huge in terms of size and required memory, but there are lightweight alternatives: Libui-node and Positron. Other lightweight platforms not based on node.js are: React-Native, XULRunner and Qt Quick with QML.
I can only speak for Electron, but 115MB sounds about right for a minimal app, the Chromium content library which Electron is based on is an all or nothing sort of thing and takes up a large chunk of that space.
After getting out of a mode of procastinating, I've finally gotten to the item on the projects todo-list that says "Run on virtual device to see why it crashes".
My project is a libgdx application that I plan on porting to various platforms, the two most important ones being desktop and android.
During development I've exclusively used the desktop launcher, as it's a lot easier to fire up when just checking minor things.
I did build an .apk at one point just to see if it'd run out of the box, but it didn't. Now that I've tried via the virtual device, this is what the log says:
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: rifleman.png
The same goes for any other assets that my game uses. The files are all placed in projectname/android/assets, as I remember learning way back that this was the way to go.
The virtual device I tried with is the stock Nexus 5, but I tried running the .apk by uploading it to my actual phone with a crash right after start, and I assume the problem is the same and is therefore unrelated to the test-platform.
I am currently not using an assetmanager, as implementing this is scheduled for after getting the basic core mechanics up and running. In the mean time I'm loading them as such: new Pixmap(new FileHandle("rifleman.png"));
Using android-studio 2.2 on Linux Mint 17 Cinnamon.
Please comment if more info is needed.
Use Gdx.files.internal() instead of FileHandle().
From filehandle(string) method info
Creates a new absolute FileHandle for the file name. Use this for
tools on the desktop that don't need any of the backends.
Do not use this constructor in case you write something cross-platform.
to gain more experience coding and support good projects, I recently got into open source projects and Github. After looking for a project I would like to work on, I found Soundnode (https://github.com/Soundnode/soundnode-app). The project uses NW.js, Node.js and Angular.js.
The question is very fundamental: How do I run the NW.js desktop app from the given files?
I was able to compile the app once, using the bash command open -n -a nwjs --args "/Users/example/path/app". But how do I compile the changes? After changing the index.html file, which is the start for the application, I have to terminate the NW.js app and start it up again (otherwise nothing will happen) and then it opens again the same, unchanged, original app (I changed some html text to see if would load the changed index.html).
Could anyone give me a quick guide how to work with this? What I want to change and everything else I will try to figure out on my own. Just need somebody to give me a head start :)
Best Regards, bbrinx - eager to learn.
nwjs application works next ways:
direct load web files from FS or web
archive files to zip package.nw
Check nwjs manual and docs: http://docs.nwjs.io/en/latest/ and https://github.com/nwjs/nw.js/wiki
Easiest way to compile your app is to use Web2Exe. It can compile for Win, Mac, Linux.
You can use browser tools for developing/debugging your application. Set toolbar option in true in window section in package.json file to see browser elements in your app.