Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nsis): add an option to opt out tauri utils plugin #9526

Closed
wants to merge 12 commits into from

Conversation

Legend-Master
Copy link
Contributor

@Legend-Master Legend-Master commented Apr 21, 2024

Add an option to replace nsis util plugin with built-in ones, this can reduce the final bundle size by ~0.8 MB

Downsides including:

  • Can't compare semver like 2.0.0-alpha.1
  • No Windows 7 support when using downloadBootstrapper option due to Windows 7 doesn't have curl installed by default doesn't have tls 1.2 enabled by default (this option is not recommended for Windows 7 anyway)

@Legend-Master Legend-Master changed the title Drop nsis util plugin in nsi script feat(nsis): add an option to not use the nsis util plugin Apr 21, 2024
@Legend-Master Legend-Master changed the title feat(nsis): add an option to not use the nsis util plugin feat(nsis): add an option to not use nsis util plugin Apr 21, 2024
@Legend-Master Legend-Master marked this pull request as ready for review April 21, 2024 11:28
@Legend-Master Legend-Master requested a review from a team as a code owner April 21, 2024 11:28
@Legend-Master Legend-Master changed the title feat(nsis): add an option to not use nsis util plugin feat(nsis): add an option to opt out tauri utils plugin Apr 21, 2024
@Legend-Master
Copy link
Contributor Author

I need to take a look at the CheckIfAppIsRunning part, it's not actually detecting the app right now

@Legend-Master
Copy link
Contributor Author

I need to take a look at the CheckIfAppIsRunning part, it's not actually detecting the app right now

Should be fixed now

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still would like to explore reducing the size of our semverCompare and process utils, I believe we can probably make these two plugins really small that we wouldn't need to use the alternatives.

core/tauri-utils/src/config.rs Outdated Show resolved Hide resolved
tooling/bundler/src/bundle/settings.rs Outdated Show resolved Hide resolved
tooling/bundler/src/bundle/windows/templates/installer.nsi Outdated Show resolved Hide resolved
Legend-Master and others added 2 commits April 22, 2024 21:35
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
@Legend-Master
Copy link
Contributor Author

I still would like to explore reducing the size of our semverCompare and process utils, I believe we can probably make these two plugins really small that we wouldn't need to use the alternatives.

I compiled it without the download one, it's around 200 KB, not too bad but definitely something we could improve

@amrbashir
Copy link
Member

I still would like to explore reducing the size of our semverCompare and process utils, I believe we can probably make these two plugins really small that we wouldn't need to use the alternatives.

I compiled it without the download one, it's around 200 KB, not too bad but definitely something we could improve

A 100kb of that are related to static CRT iirc

@amrbashir
Copy link
Member

amrbashir commented Apr 23, 2024

Sorry for the long delay, I wanted to experiment a bit and see if we can avoid having this option.

I have been doing some experiments and I have managed to reduce the size of some of our nsis plugins:

nsis-semvercompare nsis-process nsis-semvercompare & nsis-process combined in one DLL
dev 198kb 208kb 200kb
no_std 35kb 48kb 53kb
no_std (UPX) 20kb 26kb 29kb

So I think we can keep using our nsis-process and nsis-semvercompare without compromising while keeping the size very small.

The remaining bit here is the nsis-download plugin which is the most bloated of them all and unfortunately can't be written in a no_std environment, at least without too much work.

So I am proposing to remove it all together and use powershell to download the bootstrapper, this means it will fail on Windows7 and so we will need to recommend users to use embedBootstrapper when targeting Windows7.

If that's not desired, we can make this PR add an opt-out option specifically for the nsis-download plugin.

cc @lucasfernog @FabianLars

@FabianLars
Copy link
Sponsor Member

I think requiring embedBootstrapper for windows 7 is fine. We shouldn't do more than the minimum for win7 at this point imo (and remove support for it in v3).

One thing though, i am fairlyyy sure i've had issues without our download plugin on win10 too so we should triple check it! We should also check if using powershell will open a terminal window again which tbh would be a blocker for me too.

@amrbashir
Copy link
Member

One thing though, i am fairlyyy sure i've had issues without our download plugin on win10 too so we should triple check it! We should also check if using powershell will open a terminal window again which tbh would be a blocker for me too.

using nsExec::Exec with PowerShell.exe -WindowStyle hidden should not show it.

But the one thing I hate about this is that we lose the progress bar.

@Legend-Master
Copy link
Contributor Author

Legend-Master commented Apr 24, 2024

no std version seem to be promising, 50 KB is acceptable

To be honest, if we can't reduce the download plugin's size enough, there'll not be much benefit doing it this way, the bootstrap is only 1.5 MB

using nsExec::Exec with PowerShell.exe -WindowStyle hidden should not show it.

I'm pretty sure nsExec::Exec powershell -Command alone creates a hidden window

@FabianLars
Copy link
Sponsor Member

The problem i am thinking about is that when ms terminal is the default console host then the hidden window style doesn't work anymore. On win11 this isn't a problem as long as we're only downloading webview2 since all win11 installations should have that, but win10 added support for changing the default to ms terminal in later versions too and there we can't expect webview2 to be installed.

@Legend-Master
Copy link
Contributor Author

I'm pretty sure nsExec::Exec powershell -Command will create a hidden window even when you set windows terminal as default console host, I have tested this on my machine (windows 10) as least

@amrbashir
Copy link
Member

amrbashir commented Apr 27, 2024

I have been tinkering over the weekend a bit and I managed to get the dlls even smaller

nsis-semvercompare nsis-process nsis-semvercompare & nsis-process combined in one DLL
dev 198kb 208kb 200kb
no_std 35kb 48kb 53kb
no_std+upx 20kb 26kb 29kb
no_std/no_msvcrt 10kb 22kb 27kb
no_std/no_msvcrt+upx 7kb 13kb 16kb

I don't think I can get them smaller than this, so I will start looking into the download plugin

@amrbashir
Copy link
Member

amrbashir commented Apr 29, 2024

I don't know how I missed this before but looks like nsis has a built-in download plugin that is able to download the webview2 installer which is also really small in size

@amrbashir
Copy link
Member

I apologize for initially asking you to open this PR then rejecting it. I have opened tauri-apps/nsis-tauri-utils#26 for the small dll size

@amrbashir amrbashir closed this Apr 29, 2024
@Legend-Master
Copy link
Contributor Author

I don't know how I missed this before but looks like nsis has a built-in download plugin that is able to download the webview2 installer which is also really small in size

Its first line says

This built-in plugin allows you to download files via HTTP (but not HTTPS).

I did come across this but it says no HTTPS

I apologize for initially asking you to open this PR then rejecting it.

It's fine, glad to accept a better solution 😃

@FabianLars
Copy link
Sponsor Member

I did come across this but it says no HTTPS

That's probably why it works on win7 because https will fail, though i am surprised a http request against a https url works, probably only a matter of time until this breaks so we should keep an eye on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants