wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
24.87k stars 1.19k forks source link

Wails dev/build very slow on Windows compared to MacOS/Linux #2545

Open apressas opened 1 year ago

apressas commented 1 year ago

Description

Basically what the title says, go mod tidy takes longer, as does everything else, so the development loop is very very slow compared to Linux or MacOS.

To Reproduce

Build your app on Windows

Expected behaviour

Build time should be similar or at least much less than it is on Windows.

Screenshots

No response

Attempted Fixes

No response

System Details

WebView2   | N/A          | Installed | 111.0.1661.54
npm        | N/A          | Installed | 9.5.0
*upx       | N/A          | Available |
*nsis      | N/A          | Available |
* - Optional Dependency

# Diagnosis

Your system is ready for Wails development!
Optional package(s) installation details:
  - upx : Available at https://upx.github.io/
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

Additional context

No response

leaanthony commented 1 year ago

What have you tried so far to determine the slowness on your machine as I don't see this on mine?

apressas commented 1 year ago

I upgraded to version 2.4.1 and the build time has dropped to 35s from over a minute! But I still wouldn't consider this super fast. What is a normal build time for dev/build for you gus?

leaanthony commented 1 year ago

35ms is reasonable I feel...

apressas commented 1 year ago

No idea why I wrote ms, I meant seconds! And that's every time, even with no changes in the Go code.

leaanthony commented 1 year ago

Where is the time going? frontend? Go compilation. It's very fast on my Windows machine so can't reproduce.

apressas commented 1 year ago

Well I set it up on two different machines, with a clean Go installation and the same things happens. The build on my Macbook completes in seconds and the Windows machines both take over 2 minutes. The majority of time is spent on go mod tidy, which I assume builds the front end every time? That is with no changes in the code whatsoever.

leaanthony commented 1 year ago

That's really weird. go mod tidy simply ensures your local go modules are installed and up to date, a little like npm install. There's the potential for that to be slow the first time and fast on subsequent builds. All we can do is see if someone else can reproduce this because I can't.

apressas commented 1 year ago

Actually the generating bindings-compiling front end steps of go mod tidy take the longest. And then compiling the application. And it happens every time, even without changing code in the front or back end. What is a range for normal build times in seconds given modern Intel processors you'ld think?

glitchedgitz commented 1 year ago

It is slow for me too. It takes 10+ seconds each time, windows 11, 24gb ram, ryzen 5.

Even with the base project wails init -n myproject -t svelte

leaanthony commented 1 year ago

The reason I'm surprised is because Windows doesn't need CGO so it's as fast as standard Go compilation (which is famously fast). Try -skipbindings flag. I've just realised that it was never added to the docs...

leaanthony commented 1 year ago

Docs updated: https://wails.io/docs/next/reference/cli

apressas commented 1 year ago

Skipbindings did nothing. -s on the other hand sped it up by a lot but even the building steps that remain take longer than the time the mac does to build the entire thing.

glitchedgitz commented 1 year ago

For me -skipbindings time decrease from ~10s to ~ 6s, but no effects with -s. And 6 seconds is still a lot.

Btw my current approach is different to use wails because dev time was too much. As I was using pocketbase, I made all the functions to work as endpoint, so it covers the gap that wails for doing for me with obviously adding an unnecessary tasks of bindings. But this method its a lot easier to test changes and only update the frontend/backend as required.

Now when it will be time to serve the application, I will merge them together and serve it.

apressas commented 1 year ago

I didn't quite understand your solution, seems like you're not using Wails at all now, but good to know there's another way of doing it. Also running a Linux VM and building Wails apps there is much much faster than native Windows compilation. But it seems it's just not the right time to be using it for professional-grade applications.

roachadam commented 1 year ago

I also have this issue. Build takes forever on windows, with majority of time being go mod tidy and react compiling. Mac it is significantly faster alltogether, at least a half or even a third of the build time (build normal and dev)

leaanthony commented 1 year ago

How would you speed up go mod tidy or react compiling?

glitchedgitz commented 1 year ago

@leaanthony Consider my partial knowledge and let's assume if you can divide the things like this.

Now if I change the backend, it doesn't need to rebuild the core/frontend, that should save time. it will just update the binding files and the frontend framework auto-update itself when files change.

As RPC is a REST alternative, the above solution might be possible. This is similar to my current approach.

Btw my current approach is different to use wails because dev time was too much. As I was using pocketbase, I made all the functions to work as endpoint, so it covers the gap that wails for doing for me with obviously adding an unnecessary tasks of bindings. But this method its a lot easier to test changes and only update the frontend/backend as required.

leaanthony commented 1 year ago

Now if I change the backend, it doesn't need to rebuild the core/frontend, that should save time.

How can we easily detect that? The good news is that in v3 we are utilising Task to do just this but maybe you can speed things up by doing manual builds rather than use dev? I'm also still unclear as to why this might be slower on Windows than say mac

glitchedgitz commented 1 year ago

The good news is that in v3 we are utilising Task to do just this

Awesome!

How can we easily detect that?

You currently have that implemented. If I change /backend directory, just rebuild the backend and analyse if binding does need to change or not.

glitchedgitz commented 1 year ago

maybe you can speed things up by doing manual builds rather than use dev

Yeah! wails build is faster...🤔

haroflow commented 1 year ago

I started using Wails today, and it was taking ~30s to reload changes on app.go...

Just noticed that MsMpEng.exe (Windows Defender) starts running when I save app.go... after deactivating it, went from ~30s to ~8s. Still not ideal, but it helps...

Other info: Windows 10 Wails CLI v2.5.1 WebView2 114.0.1823.51 Nodejs 16.13.2 npm 8.1.2 Template: https://github.com/mateothegreat/wails-template-angular

leaanthony commented 1 year ago

Ah, that may well be the issue!

mmghv commented 1 year ago

Just noticed that MsMpEng.exe (Windows Defender) starts running when I save app.go... after deactivating it, went from ~30s to ~8s. Still not ideal, but it helps...

I can confirm, build went down from ~60s to 10s, and dev from 33s to to 22s

Although I didn't disabled Windows Defender, I just added go process to the exclusion list : Windows Defender > Exclusions > Add an exclusion > Process > C:\Program Files\Go\bin\go.exe And while I'm at it I added VSCode and Node.

Note : It's important to add the exclusion as a Process and not a File so it excludes any child process that Go spawns, adding it as a file/folder exclusion didn't give the same results.

DISCLAIMER : DO IT AT YOUR OWN RISK