Blazor AOT dotnet.wasm is too big - blazor-webassembly

We have a Blazor application, which we compile with AOT. The output dotnet.wasm is approximately 300 MB. And when we run the app, it uses 3GB of RAM in the Browser. And as a result, the app works slow, significantly slower compared to the Interpreter mode.
Is there a way to reduce the size of dotnet.wasm and the memory consumption?
Are there any tools to analyze it?
.NET SDK (reflecting any global.json):
Version: 6.0.100-rc.1.21463.6
Commit: e627d556a1
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-rc.1.21463.6\
Host (useful for support):
Version: 6.0.0-rc.1.21451.13
Commit: d7619cd
There is an issue for .NET 6 Preview 3,4,7, RC1
Maybe we attached too many 3rd party libraries. Is there a way to understand which libraries cause the issue?

Related

Application could not be uploaded to the device

Following are the details about Xamarin, studio and Mac:
Visual Studio Community 2019 for Mac
Version 8.6.8 (build 2)
Xamarin.Mac 6.18.0.23
.NET Core SDK
SDK: /usr/local/share/dotnet/sdk/3.1.302/Sdks
SDK Version: 3.1.302
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks
.NET Core Runtime
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
3.1.6
2.1.20
Xamarin.Profiler
Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater
Version: 11
Apple Developer Tools
Xcode 12.0 (17189.4)
Build 12A8169g
Xamarin.iOS
Version: 13.18.2.1 (Visual Studio Community)
Operating System
Mac OS X 10.15.6
Darwin 19.6.0 Darwin Kernel Version 19.6.0
Issue:
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mlaunch -sdkroot "/Applications/Xcode-beta.app/Contents/Developer" --installdev "/Users/*******/Projects/testApp/testApp/bin/iPhone/Debug/device-builds/iphone11.6-13.5.1/testApp.app" --device ios "--devname=iPhone XS Max" --install-progress
error HE0004: Could not load the framework 'IDEKit' (path: /Applications/Xcode-beta.app/Contents/Frameworks/IDEKit.framework/IDEKit): dlopen(/Applications/Xcode-beta.app/Contents/Frameworks/IDEKit.framework/IDEKit, 1): Library not loaded: #rpath/DVTAnalyticsKit.framework/Versions/A/DVTAnalyticsKit
Referenced from: /Applications/Xcode-beta.app/Contents/Frameworks/IDEKit.framework/Versions/A/IDEKit
Reason: image not found
All the paths are correct and file exist there.
This is just a sample project and its failing to deploy on physical device. I am able to deploy via XCode but it fails via Mac Visual Studio. Need some help here. I am going to install different version of XCode and try it.
If you are using Xcode 12 beta you need a newer version of Xamarin.iOS from the xcode12 branch. Quoting from the wiki on how to get a build from the said branch:
If you go to our commits page you should be able to see a green checkmark (✔) or a red cross mark (✘) at the right side of the committer's handle. If you click the checkmark (it's usually best to use builds with green checkmarks, but in some cases there may be none, in which case you can likely use builds with red checkmarks as well) you should see a details link which will provide download links for both Xamarin.iOS and Xamarin.Mac packages for that specific commit. Once in a while a commit may not have associated builds (this can occur both for red and green builds) - just try a different commit.
Make sure you download the "Notarized" version of the pkgs.
Uninstalled Xcode 12 beta and installed Xcode 11.6 (Hosted in VM).
It worked successfully.
Now i am able to deploy from Visual Studio 2019 running on windows.

How to deploy asp.net core 2.1 preview app to azure?? how do i install the new sdk in azure

I upgraded to .NET Core 2.1 Preview 1 SDK and I installed the asp.net core 2.1 preview site extension by following the instruction on the below link
https://blogs.msdn.microsoft.com/webdev/2018/02/27/asp-net-core-2-1-0-preview1-using-asp-net-core-previews-on-azure-app-service/
Expected behavior
expect the newly released sdk to be installed for azure web app
Actual behavior
running dotnet --info on the web app console screen gives the below result:
D:\home\site\wwwroot
dotnet --info
D:\home\site\wwwroot
.NET Command Line Tools (2.1.4)
Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x86
Base Path: D:\Program Files (x86)\dotnet\sdk\2.1.4\
Microsoft .NET Core Shared Framework Host
Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54
anyone knows how to deploy my asp.net core 2.1 preview app to azure?
Before you run dotnet --info, you should check that the extension is indeed installed:
You can either go through the linked instruction again or follow my approach:
go to your scm site: https://<yourWebSiteName>.scm.azurewebsites.net/SiteExtensions#gallery
install dotnet core runtime siteextensions
verify that it is installed and restart the site

Deploying .net Core web app to ubuntu linux

I had an app I was developing in asp.net 4.5 and I wanted to move it to asp.net core and run on linux server (ubuntu).
I've been having a number of challanges and unfortunately current documentation is not helpful.
so...
How should I package the app?
The tech docs suggest building with the following command
dnu publish --runtime dnx-coreclr-linux-x64.1.0.0-rc1-update1
However I tried this on my local machine and it didn't have option to deploy linux version. When I run on server it comes up with a number of problems (covered later). So should I do this on server or get working on local machine.
NB: I read in another stack overflow question that as long as its coreclr it doesn't matter whether its win or linux?
I imagine after this is answered more questions will emerge..I've had so many issues with Core I'm wondering whether anybody has actually manged to deploy on app to Linux environment!
Any help would be greatly appreciated!
Update
To provide further information current runtimes on local machine are...
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta5 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x86 C:\Users\Alex.dnx\runtimes
* 1.0.0-rc1-update2 clr x86 C:\Users\Alex.dnx\runtimes default
1.0.0-rc1-update2 coreclr x86 C:\Users\Alex.dnx\runtimes
I want to compile it as coreclr linux....however when I run the dnu publish command above it says runtime doesn't exist even though I update coreclr from nuget?
Do I need to specify an OS (linux or windows) when I build it or will a single published app run on both if its coreclr?
This runs fine when imported into Azure but doesn't work when deployed to linux
OK, here's how to:
Install Visual Studio 2017 (with .NET Core)
Create your project, and get it to compile on Windows
Once it compiles and runs, make sure you can publish it from Visual Studio
Once you can publish it from Visual Studio, close Visual Studio and do the following
open cmd.exe (Windows-Key + R)
cd "directory of your .sln file"
dotnet restore -r ubuntu.16.04-x64
dotnet build -r ubuntu.16.04-x64
dotnet publish -f netcoreapp1.1 -c Release -r ubuntu.16.04-x64
Your application should now be in folder bin/publish
A list of RIDs (-r) can be obtained here and here.
If you want to develop on Linux, run
apt-get install dotnet-dev-1.0.1
and the dotnet-utility should run on Linux.
Note that if you get
C:\Program
Files\dotnet\sdk\1.0.0\Microsoft.Common.CurrentVersion.targets(2865,5):
error MSB3554: Cannot write to the output file "C:\path\to\your\project\obj\Debug\netcoreapp1.1\YOUR_APP.Properties.Resources.resources".
Positive number required.
Build FAILED.
when you run the build or publish command, just run the command again.

Running OpenCL code on intel CPU

Now I'm testing running OpenCL source code on intel cpu.
I used the source code on this page (http://lava.cs.virginia.edu/Rodinia/download_links.htm)
I selected 2.4 version and certainly used NW-algorithm source code located in ../opencl/nw/ .
My environment is Windows 7 64bit OS / Intel(R) Xeon(R) CPU W3530 / NVIDIA Quadro 600 .
I installed visual studio 2013 and NVIDIA 6.0 CUDA tookit .
At first, I could run this source on my gpu. And It operates very well.
But when I set use_gpu = 0 (this means CL_DEVICE_TYPE_CPU), program stoped at the first of opencl API function line. (maybe clGetPlatformIDs)
So I installed 64bit CPU only runtime on (https://software.intel.com/en-us/vcsource/tools/opencl-sdk) and Intel SDK for OpenCL Applications 2014 Beta version on (https://software.intel.com/en-us/vcsource/tools/opencl-sdk-beta).
But when I ran this file again, I got
'OpenCLProject2.exe' (Win32): Loaded 'C:\Windows\System32\ntmarta.dll'. Symbols loaded.
'OpenCLProject2.exe' (Win32): Loaded 'C:\Windows\System32\Wldap32.dll'. Symbols loaded.
'OpenCLProject2.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\cpu_device64.dll'. Cannot find or open the PDB file.
'OpenCLProject2.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Intel\OpenCL\bin\x64\tbb\tbb.dll'. Cannot find or open the PDB file.
The thread 0x1438 has exited with code -1 (0xffffffff).
The program '[4480] OpenCLProject2.exe' has exited with code -1 (0xffffffff).
this messages and clCreateContextFromType API returns error.
At this point I can't proceed my work.
I wonder why error lines include (Win32) or (x86) or System32 although I installed windows7 64bit OS and 64bit version of CPU only runtime.
Give me some advice. Thx.

CL_DEVICE_NOT_AVAILABLE using Intel Core 2 Duo E8500 CPU

I get the error CL_DEVICE_NOT_AVAILABLE when running this sample code. However, unlike in that question, my CPU, the Intel Core 2 Duo E8500 CPU, appears to be supported. I've made sure to link against the Intel version of the OpenCL libraries, since I also have the Nvidia libraries installed. Why is this error occurring?
The Intel OpenCL SDK 2013 required SSE 4.2. From what I can tell (here) the Intel Core 2 Duo E8500 CPU only has SSE 4.1
"CL_DEVICE_NOT_AVAILABLE" is the error you get when you try to create an OpenCL device on an unsupported CPU.
The good news for you is that the Intel OpenCL SDK 2012 works on SSE 4.1; you should uninstall the 2013 SDK and use the 2012 SDK instead (or get a newer CPU).
"CL_DEVICE_NOT_AVAILABLE" has nothing to do with the SDK. It's due to the OpenCL device driver which is part of the video card device driver.
It's common to confuse the SDK and the OpenCL device driver. You develop the host code with the SDK but the kernel is compiled and run through the device driver. I often develop with the Intel SDK but I run my kernels on the CPU using the Intel video driver or the AMD Radeon drivers and on the GPU using the Nvidia video drivers (GTX590). I have all three video drivers installed in Windows. You don't have to have an AMD video card to instal the Radeon drivers.
So in your case you can use the AMD drivers to run your kernel on the CPU. They are much less restrictive than Intel's.
On windows I get faster results running my Kernel on my Sandy Bridge CPU using the Intel OpenCL drivers than AMD. However, on Linux the AMD driver runs my kernel faster on my Intel CPU than the Intel driver does.
I encountered this error while creating a tutorial on how to install hashcat on Ubuntu 18.04; I've included the instructions below for Installing OpenCL™ Runtimes for Intel® Processors - Option A (Recommended)- feel free to review my full gist on GitHub. Hope that helps!
Installing OpenCL™ Runtimes for Intel® Processors
Installing OpenCL™ Runtimes for Intel® Processors - Option A (Recommended)
Check your CPU system processor architecture by running sudo lscpu to identify the class of CPU e.g. "Intel (R) Core (TM) i7-7700 CPU # 3.60Ghz"- alternatively, you can go to Settings > Details which will also reveal the CPU-family (e.g. Intel (R) HD Graphics 630 (Kaby Lake GT2)).
Go to the Intel Developer Zone and scroll down to the corresponding download link for your system; assuming you're running Ubuntu 18.04 and have a Intel Core-class CPU, scroll down to "Linux* OS Ubuntu* 16.04.x (deb)" and click on the Github link for 18.46.11837 Runtimes to access the runtime-packages to download.
There should be instructions within the aforementioned Github repo- or you can proceed with the following in the next steps.
cd ~/Desktop
mkdir neo
cd neo
sudo wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-gmmlib_18.4.0.348_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-igc-core_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-igc-opencl_18.44.1060_amd64.deb
wget https://github.com/intel/compute-runtime/releases/download/18.46.11837/intel-opencl_18.46.11837_amd64.deb
Install the packages by running sudo dpkg -i *.deb.
Restart the system by running sudo reboot.
Installing OpenCL™ Runtimes for Intel® Processors - Option B
Go to Intel OpenCL Runtimes website and scroll down to the bottom of the page to Download Intel CPU Runtime for OpenCL Applications 18.1 for LINUX OS (64-bit only).
After downloading the OpenCL Runtimes for Intel Processors, cd ~/Downloads
Run sudo tar -xzf l_opencl_p_18.1.0.013.tgz to unpack the tgz file- please note, the OpenCL file version may update since the time as of this gist (ie as of this gist, the version is 18.1.0.013.)
cd l_opencl_p_18.1.0.013
Run sudo ./install.sh
A welcome screen is prompted- hold-down the "Enter" key until able to input select "2" for "I do NOT consent to the collection of my Information"
Hit "1"
Hit "1"
Hit "Enter" and then restart the computer.
If any additional Intel OpenCL errors are encountered after testing hashcat, go to section 'Installing OpenCL™ Runtimes for Intel® Processors - B'- if not, proceed with section "Testing Hashcat"

Resources