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

[browser][MT]Download phase stalling. #108253

Open
Tewr opened this issue Sep 25, 2024 · 3 comments
Open

[browser][MT]Download phase stalling. #108253

Tewr opened this issue Sep 25, 2024 · 3 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration os-browser Browser variant of arch-wasm
Milestone

Comments

@Tewr
Copy link

Tewr commented Sep 25, 2024

Hello,

I'm looking into supporting my library BlazorWorker on .net9. I'm having some trouble initializing dotnet using the same code as in .net8. I run into a kind of deadlock-looking situation in the download phase after calling await dotnet.create();, basically this call never returns, and it seems that after all the downloads have finished, we are awaiting some promise, somewhere... forever. The call is here: https://github.com/Tewr/BlazorWorker/blob/4aca2b9b3f9322e930c9495c4334293408b4f2ab/src/BlazorWorker/BlazorWorker.js#L165

I have tracked down the issue to something that might be related to parallel downloads in the initialization phase (is this new?). If I fiddle around in these methods, setting breakpoints and stuff, occasionally but sporadically the initialization phase will succeed. I have tried changing the maxParallelDownloads value to something lower but with limited success. So it's clearly some kind of sync problem. But in general, the slower the code is executing, the higher the chance of success, I think.

Maybe if I could get a better understanding of this parallel download mechanism I can find a way around this deadlock-looking situation? I have seen that there have been some multithreading work as well, so possible some kind of detection of me being inside a worker that may mess things up.

@pavelsavara has commited the code and has had some small interaction with my library in the past. I'd be happy for any insights. I'm particularly looking at this method start_asset_download_with_throttle. I'm note sure if it's the right spot, but I feel like it's around here somewhere where the hangup occurs.

async function start_asset_download_with_throttle (asset: AssetEntryInternal): Promise<AssetEntryInternal> {
.

Original issue, with code to reproduce the problem
Tewr/BlazorWorker#111

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 25, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Sep 25, 2024
@teo-tsirpanis teo-tsirpanis added the arch-wasm WebAssembly architecture label Sep 25, 2024
@lewing lewing removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 25, 2024
@lewing lewing added this to the 10.0.0 milestone Sep 25, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Sep 25, 2024
@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Sep 25, 2024
@pavelsavara
Copy link
Member

Could you please create full demo for me that I could test ? Give me a zip with self-hosted blazor-wasm that I can try to fiddle with.

@pavelsavara pavelsavara added the needs-author-action An issue or pull request that requires more info or actions from the author. label Sep 27, 2024
@Tewr
Copy link
Author

Tewr commented Sep 28, 2024

Sure thanks!

I created a branch for you
https://github.com/Tewr/BlazorWorker/tree/feature/net9-demo-loader-problem

So you can directly download the zip from https://github.com/Tewr/BlazorWorker/archive/refs/heads/feature/net9-demo-loader-problem.zip

The self-hosted blazor-wasm server project for .net9 is here:
https://github.com/Tewr/BlazorWorker/blob/feature/net9-demo-loader-problem/src/BlazorWorker.Demo/Net9/BLazorWorker.Demo.Client/BlazorWorker.Demo.Client.csproj

You need to hit the "run test" button on the first page to initiate

@dotnet-policy-service dotnet-policy-service bot added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Sep 28, 2024
@Tewr
Copy link
Author

Tewr commented Sep 28, 2024

I've fiddled a bit more this morning, and I can see there is a link to the cache (I guess in this case it's the assets cache): If I do a hard cache reset in the browser and have the debugger open (to slow things down), the success rate (with success, I mean I manage to get past await dotnet.create()) is a lot higher. I occationally succeed without the debugger open as well, but always after a hard cache reset in chrome

rather than the cache itself could also just be the impact on speed, like, works better if slower

@pavelsavara pavelsavara changed the title Download phase stalling. [browser][MT]Download phase stalling. Oct 2, 2024
@pavelsavara pavelsavara modified the milestones: 10.0.0, Future Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration os-browser Browser variant of arch-wasm
Projects
Status: No status
Development

No branches or pull requests

4 participants