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

Error when trying to use compression (Brotli) in Blazor WASM: "Uncaught (in promise) Corrupted padding bits " #45191

Closed
1 task done
sturlath opened this issue Nov 20, 2022 · 19 comments
Labels
area-blazor Includes: Blazor, Razor Components Docs This issue tracks updating documentation feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly Pillar: Technical Debt

Comments

@sturlath
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have been trying to get my Blazor WASM project to compress to avoid the 100 MB over 30-50 sec load time I´m currently having and have been trying to compress the files and serve Brotli (.br) files to my client. I have gone over the documentation and tried all I can think of (see what I have now).

image

I´m using the abp.io framework and thought that they were missing something but they have managed to get the same error from an file-new-Blazor-WASM-project

Expected Behavior

Blazor WASM client/browser gets served only .br files (not 100MB of .dll´s) and loads without any console errors in faster time rate than 30-50 sec

Steps To Reproduce

Here is my file-new-project-code-example (I tried min and max version of the decode.js file) and here is the code pushed to Azure.

For some reason I´m getting a different error than @realLiangshiwei is getting here
image

Exceptions (if any)

image

.NET Version

6.0.302

Anything else?

Locally I run on Windows and Visual Studio latest preview version. The app in Azure is just AppService. I have been struggling to get my Blazor WASM to perform since summer without any luck and am hoping we can figure out this compression issue.

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly labels Nov 21, 2022
@javiercn
Copy link
Member

@sturlath thanks for contacting us.

The repro is not accessible.

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Nov 21, 2022
@ghost
Copy link

ghost commented Nov 21, 2022

Hi @sturlath. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@sturlath
Copy link
Author

Sorry @javiercn its open now!

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 21, 2022
@javiercn
Copy link
Member

@sturlath Seems like you are using a custom library to decompress the brotli stream and the error is coming from it.

Could you try using the BrotliStream class from .NET to decompress the stream to see if you happen to have the same issue with the file that fails?

From what I can tell, it is likely an issue in the library you are using.

@MackinnonBuck
Copy link
Member

@sturlath Could you please try following the approach that https://github.com/aspnet/quickgridsamples/tree/main/src/QuickGridDemos uses? Thanks.

@MackinnonBuck MackinnonBuck added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 21, 2022
@ghost
Copy link

ghost commented Nov 21, 2022

Hi @sturlath. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@sturlath
Copy link
Author

@javiercn are you talking about the code in the decode.min.js?

That code comes from your docs where it points to these files here.

That is the only "custom" library I have added.

Btw I just took the none-minified code and inserted it into the decode.min.js file after seeing this here
image

But as you can see now (I just updated it) and it still has the same issue.


Could you try using the BrotliStream class from .NET to decompress the stream to see if you happen to have the same issue with the file that fails?

Any change you can point me to some code that I can work with to change the current implementation with?

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Nov 21, 2022
@sturlath
Copy link
Author

Sorry @MackinnonBuck I didn´t see your comment until now.

But I get this
image

But I found this here but can´t find any compression code...

image

@javiercn
Copy link
Member

@sturlath can you check that the stream that you are downloading is actually Brotli compressed?

Just in case there is a configuration issue on the server and is sending an uncompressed version. Can you log at least the filename/url that is causing the failure?

@sturlath
Copy link
Author

Not sure how I can check the stream since I just hit errors and don´t see anything in the console. This is the url https://blazorbrotli20221120112426.azurewebsites.net

I just pushed it to azure (this time) with Visual Studio (default.. no extra settings)

image

you can see some .br files there

image

@javiercn
Copy link
Member

@sturlath I was suggesting you put a log statement here. To see what exact file is causing problems:
https://github.com/sturlath/BlazorBrotli/blob/master/BlazorBrotli/wwwroot/index.html#L26

Maybe update the code to put it inside a try-catch and log the name/url of the resource it was trying to decode.

@sturlath
Copy link
Author

sturlath commented Nov 22, 2022

@javiercn I added the logs. Does this help? Anything else I can try out? Isn´t there some Blazor WASM compression example you have I can try out and publish to see how that works out?

image

@javiercn
Copy link
Member

@sturlath from what I can tell in your code, the problem is that it is trying to load blazor.boot.json and not blazor.boot.json.br

@sturlath
Copy link
Author

@javiercn is that a server setting (I havent read anything on that) or something I can influence in code? And how? Do you know of any docs that might help?

@mkArtakMSFT
Copy link
Member

Looks like the issue is because the .br files aren't accessible on your server. If they're not there, they should have been deployed too. If they are present on the server, then the server should be configured to make them accessible.
We'll keep this issue around to address any gaps in our docs to cover this.

@mkArtakMSFT mkArtakMSFT added Docs This issue tracks updating documentation and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Nov 22, 2022
@mkArtakMSFT mkArtakMSFT added this to the .NET 8 Planning milestone Nov 22, 2022
@ghost
Copy link

ghost commented Nov 22, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@SteveSandersonMS
Copy link
Member

@sturlath Yes, it probably is a server setting. Azure hosted apps may return 404 for unconfigured file extensions, such as .br, so you likely need to configure it to serve those files. I think it's equivalent to this StackOverflow question where somebody wants to make the server return .woff files: https://stackoverflow.com/questions/29334564/getting-404-error-for-font-files-with-azure-hosted-app-tried-adding-mime-type

@sturlath
Copy link
Author

Thank you @SteveSandersonMS! That fixed the issue with the example. It now fetches the .br files.

image

I will now check if this fixes my original issue with my product. I´ll report back.

@ghost
Copy link

ghost commented Oct 6, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Docs This issue tracks updating documentation feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly Pillar: Technical Debt
Projects
None yet
Development

No branches or pull requests

5 participants