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

MAUI Hybrid Blazor: Significant Build Time Increase in .NET 9 Debug Mode Compared to .NET 8 #44932

Open
SaleSwift opened this issue Nov 17, 2024 · 10 comments
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@SaleSwift
Copy link

SaleSwift commented Nov 17, 2024

When building a MAUI Hybrid Blazor app in Debug mode locally with .NET 9, the build process takes significantly longer than with .NET 8. Specifically:

.NET 9: ~15 minutes per build.
.NET 8: ~3 minutes per build (70% faster).
This issue is highly disruptive during development, particularly for local debugging and iterative development cycles.

This issue is critical and must be resolved as it severely impacts development productivity.
Me and my entire development team are unable to work effectively with .NET 9 in our development environment due to this issue.

Project Structure:

MAUI Project: This project handles the platform-specific aspects of the application. It takes an excessively long time to build in .NET 9.
MAUI Shared Project: Contains shared Razor files and logic. This project builds very quickly, even in .NET 9.
The problem specifically lies with the MAUI project, while the Shared project does not exhibit the same slow build times.

Steps to Reproduce:
Upgrade a MAUI Hybrid Blazor project from .NET 8 to .NET 9.
Run a local Debug build.
Compare the build time with the same project in .NET 8.

Expected Behavior:
Build times in .NET 9 should be comparable to or faster than .NET 8.

Environment:
MAUI Hybrid Blazor application.
Local development machine.

Actual Behavior:
Build times in .NET 9 are significantly slower, resulting in delays and impacting development productivity.

Additional Context:
This issue persists across multiple attempts and affects both new projects and projects upgraded from .NET 8.

Urgency:
This bug must be addressed immediately, or guidance must be provided to help us resolve it, as it completely blocks our ability to use .NET 9 in a development environment.

Steps to Reproduce

Upgrade a MAUI Hybrid Blazor project from .NET 8 to .NET 9.
Run a local Debug build.
Compare the build time with the same project in .NET 8.
Expected Behavior:
Build times in .NET 9 should be comparable to or faster than .NET 8.

Link to public reproduction project repository

No response

Version with bug

9.0.10 SR1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.10 SR1

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Copy link

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

@jfversluis
Copy link
Member

Please don't keep opening new issues about the same problem. We'll lose the earlier context. Thanks!

@SaleSwift
Copy link
Author

Please don't keep opening new issues about the same problem. We'll lose the earlier context. Thanks!

Hi @jfversluis , thanks for your response! I really need help with this issue as it’s completely blocking my team from working with .NET 9 in our MAUI Hybrid Blazor projects. Is there someone who can assist us in resolving this? Appreciate your support!

@jfversluis
Copy link
Member

In the previous issue I asked for a binlog with instructions on how to get it. Unfortunately, those were not provided and so its impossible to understand what exactly is the cause of this.

If this is really blocking you right now, I would recommend going back to .NET 8 for now for your main work and then provide the requested details so we can investigate and advise and then you can try those out before you upgrade definitively.

@SaleSwift
Copy link
Author

In the previous issue I asked for a binlog with instructions on how to get it. Unfortunately, those were not provided and so its impossible to understand what exactly is the cause of this.

If this is really blocking you right now, I would recommend going back to .NET 8 for now for your main work and then provide the requested details so we can investigate and advise and then you can try those out before you upgrade definitively.

Thank you for your response and guidance.

Building via Command Line
I attempted to build the project using the following command:

dotnet build myproject.csproj /bl:msbuild.binlog
Duration: The build completed in approximately 430 seconds (~7 minutes).
Observation: While this is a reasonable build time, it does not reflect the real scenario as I primarily use Visual Studio for development.
URL : https://drive.google.com/file/d/17t4wlrUsDlgOhnizlJVf2jSSm6zL8vQO/view?usp=drive_link (CMD build Log)

Building via Visual Studio
I also built the project through Visual Studio and captured the .binlog file for this process.

Duration: The build took approximately 22 minutes to complete.
Observation: This is the real issue, as the build times in Visual Studio are significantly longer than the command-line build.

https://drive.google.com/file/d/1L0-dgMaw9pu4hsIZt0YzV3qsETDi5ISM/view?usp=drive_link (Visual studio build Log)

Note:
I have uploaded both .binlog files to Google Drive because their sizes exceed GitHub's upload limit of 25 MB. Please let me know if there’s any further information I can provide or additional steps I should take.

@jfversluis

@TimPurdum
Copy link

I feel like this is possibly related to this one I just opened, or at least I am experiencing both together. I just had a MAUI build time of 36 minutes for a project with an RCL. dotnet/aspnetcore#59014

@SaleSwift
Copy link
Author

Drive links access are currently set to public

Is there any updated releated to this issue ?

@jfversluis

@SaleSwift
Copy link
Author

I feel like this is possibly related to this one I just opened, or at least I am experiencing both together. I just had a MAUI build time of 36 minutes for a project with an RCL. dotnet/aspnetcore#59014

I hope the maui or visual studio team have workaround to fix this issue until they do an update

@javiercn
Copy link
Member

javiercn commented Nov 18, 2024

@SaleSwift we've started looking at this.

The slowdown seems to be caused by some of the new features we added in .NET 9.0. Your app seems to contain a large number of assets (16K assets) and that is adding a lot of processing time. Most of the assets you are bringing are icons, which are unlikely to be used by the app.

We are working to improve the experience in the SDK for apps with a large amount of assets, however, there are a few things that you can do today to avoid these problems:

  • Disable compression by setting up <CompressionEnabled>false</CompressionEnabled> on your csproj file. This is not needed in Maui apps, and it'll likely cut the build time in half.
  • Remove any assets that you aren't using from the Content item group.
    • For example. you seem to be bringing in all the docs files from several libraries as assets -> wwwroot\assets\icon-fonts\bootstrap-icons\icons\docs\ and wwwroot\assets\libs\chart.js\docs\
    • Any other set of assets that you are not using in your app and can remove, you should.

We have some performance improvements coming down in a future release to better handle these scenarios even if the assets are not being used, but that doesn't mean you shouldn't trim the set of assets in your app to those you use, as otherwise it'll bloat your app size and slow down the build

@PureWeen PureWeen transferred this issue from dotnet/maui Nov 18, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Nov 18, 2024
@SaleSwift
Copy link
Author

@SaleSwift we've started looking at this.

The slowdown seems to be caused by some of the new features we added in .NET 9.0. Your app seems to contain a large number of assets (16K assets) and that is adding a lot of processing time. Most of the assets you are bringing are icons, which are unlikely to be used by the app.

We are working to improve the experience in the SDK for apps with a large amount of assets, however, there are a few things that you can do today to avoid these problems:

  • Disable compression by setting up <CompressionEnabled>false</CompressionEnabled> on your csproj file. This is not needed in Maui apps, and it'll likely cut the build time in half.

  • Remove any assets that you aren't using from the Content item group.

    • For example. you seem to be bringing in all the docs files from several libraries as assets -> wwwroot\assets\icon-fonts\bootstrap-icons\icons\docs\ and wwwroot\assets\libs\chart.js\docs\
    • Any other set of assets that you are not using in your app and can remove, you should.

We have some performance improvements coming down in a future release to better handle these scenarios even if the assets are not being used, but that doesn't mean you shouldn't trim the set of assets in your app to those you use, as otherwise it'll bloat your app size and slow down the build

Thank you so much for your help . After removing the unused assets, the build time was reduced to around 2.5 minutes, which is a 90% improvement! It was still a bit strange to me that .NET 8 was faster, but your advice about removing unused assets really made a huge difference.

Since you mentioned there are some performance improvements coming in a future release, would you recommend keeping the issue open until those updates are available, or should I go ahead and close it for now? Let me know what would be best.

Thanks again for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants