runtime: aspnetcore 8 preview 4 blazor wasm size regression

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The minimum size of blazor wasm app in .net 7 is 1.1 MB but in dotnet 8 this is 1.3 MB (200KB compressed size increase)

Expected Behavior

I’d expect size to be 1.1 MB (Or even less ;D !)

Steps To Reproduce

1- Run followings for .NE 7 & 8:

dotnet workload install wasm-tools
dotnet workload install wasm-experimental

2- Create 2 empty blazor wasm projects for .NET 7 & 8

3- Remove <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> and corresponding http client registrations codes (blazor empty project template is not as empty as you might expect!)

4- Add followings to the csproj’s PropertyGroup section:

<InvariantGlobalization>true</InvariantGlobalization>
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport>
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData>

Publish both projects and compare sizes in Edge Dev Tools Network

.NET 7: image

.NET 8: image

Exceptions (if any)

No response

.NET Version

8.0.100-preview.4.23260.5

Anything else?

.NET SDK:
 Version:   8.0.100-preview.4.23260.5
 Commit:    2268e7b15c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.20348
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.4.23260.5\

.NET workloads installed:
 [maui]
   Installation Source: SDK 8.0.100-preview.4
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [maui-ios]
   Installation Source: SDK 8.0.100-preview.4, VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [maui-maccatalyst]
   Installation Source: SDK 8.0.100-preview.4, VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [maui-tizen]
   Installation Source: SDK 8.0.100-preview.4
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [wasm-experimental]
   Installation Source: SDK 8.0.100-preview.4
   Manifest Version:    8.0.0-preview.4.23259.5/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.workload.mono.toolchain.current\WorkloadManifest.json
   Install Type:              Msi
 [wasm-tools]
   Installation Source: SDK 8.0.100-preview.4, VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.23259.5/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.workload.mono.toolchain.current\WorkloadManifest.json
   Install Type:              Msi
 [android]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    34.0.0-preview.4.273/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.android\WorkloadManifest.json
   Install Type:              Msi
 [maccatalyst]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    16.4.8377-net8-p4/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maccatalyst\WorkloadManifest.json
   Install Type:              Msi
 [maui-windows]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [ios]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    16.4.8377-net8-p4/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.ios\WorkloadManifest.json
   Install Type:              Msi
 [maui-android]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.8333/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.sdk.maui\WorkloadManifest.json
   Install Type:              Msi
 [wasm-tools-net6]
   Installation Source: VS 17.7.33711.374
   Manifest Version:    8.0.0-preview.4.23259.5/8.0.100-preview.4
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100-preview.4\microsoft.net.workload.mono.toolchain.net6\WorkloadManifest.json
   Install Type:              Msi

Host:
  Version:      8.0.0-preview.4.23259.5
  Architecture: x64
  Commit:       84a3d0e37e

.NET SDKs installed:
  7.0.102 [C:\Program Files\dotnet\sdk]
  7.0.302 [C:\Program Files\dotnet\sdk]
  7.0.400-preview.23225.8 [C:\Program Files\dotnet\sdk]
  8.0.100-preview.4.23260.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.0-preview.4.23260.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.0-preview.4.23259.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.4.23260.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 3
  • Comments: 15 (15 by maintainers)

Most upvoted comments

BlazorEnableTimeZoneSupport will work again in preview 7

I think this may be resolved by changes in blazor in rc1 please follow up after testing .NET rc1

Thank you very much for the details on how to reproduce the issue, it will be very helpful to be able to match your numbers while testing!

Thank you for sharing the demo, I will do some investigation into the file sizes to see if I can determine whether the increase is a result of any bugs we can fix or if there are some improvements we can make in 8.

@kg

https://todo.bitplatform.dev/

This is a demo of our Project Template, which includes Authentication & Authorization, a UI Toolkit, Font Icon, Dark / Light Theme, etc., and is 3.1 MB in size. In .NET 8, it becomes 3.3MB (about 7% increase)

The issue here is that the size of Blazor Web Assembly is relatively high compared to JavaScript Frontend libraries & frameworks. It seems that this 200KB increase in size has been more of a mistake, not by design.

So, I thought it would be better to point it out.

This 200KB, in its uncompressed form, is 700KB, this means additional decompression overhead is added.

Dear @kg , first off, I want to sincerely thank you for your attention to this matter. At first glance, 200KB might not seem like much, but collectively, the 43 components that we have developed, which include the File Uploader, Date Picker, Drop Down, and more, along with DLL, JS, and CSS, make up a volume of 200KB!

Our goal is to bring Blazor from its current space, which is mainly used for admin panels and enterprise apps where size and startup time aren’t as critical, to the realm of mobile apps and public websites that are SEO-friendly and super fast. We’ve put in a lot of effort towards this goal over the past two years.

In continuation, I’ve included a picture for you that shows exactly this Url you have opened, and the transferred volume is 3.1 megabytes.

image

In the next picture, you will see the 6.5 that you had seen before.

image

As you can see, this is a PWA site and, practically speaking, you won’t have any downloads from the second time onward. In the second picture (the one above), the transferred volume is zero. To test this, temporarily disconnect your internet, refresh the site, and you’ll see that it loads (although you won’t be able to log in because you won’t have server access). If you can’t disconnect your internet, in the Network section of the same browser Dev Tools where you’re viewing these sizes, set the drop-down related to Throttling to Offline.

Now, what is that 6.5? 6.5 is the volume of uncompressed resources that the browser has tried to download, and in practice, zero bytes have been downloaded because the PWA responded with all from its cache. This 6.5 was 14.3 in the first picture, and these two numbers, 14.3 and 6.5, essentially have no place in our calculations, and the important volume for us is the transferred one, which is 3.1 for the first time and 0 for the second time. When I talk about an increase in volume by 200KB, I mean that this 3.1 becomes 3.3.

How can you reach the first picture? In the DevTools, similar to the picture below, while checking all options, click on ‘Clear site data’ or simply test in the browser’s Incognito or Private mode.

image

I’ve been following your work since the old times and I’m really happy that you are investigating this issue, although I understand that one cannot expect fundamental changes in a short period. Right now, my goal is merely to report the size regression.

Let’s get back to the main issue, that is the increase in volume in dotnet 8, which I had tested on an entirely empty project: The transferred size has increased by 200KB, which represents 700KB of uncompressed resources derived from the difference of 3.9MB and 3.2MB in the picture below.

image

Where does this 700KB out of 3.0MB in this picture, or the same 14.3MB in my first picture, become important? It becomes important when the storage of the client device is weak and the second time the site is loaded from its cache, the weak storage is such that even reading 193 files with a volume of 14.3MB can be problematic for it, for example low-mid end Android phones)

It’s natural that the more we reduce the amount of transferred volume, which is compressed, the more we have effectively reduced the volume of the resources, in addition to reducing the decompression cost at the first site opening.

Regards