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

[WASM] Browser tab crashes when dotnet-crypto-worker.js fails to connect to WebSocket #72941

Closed
simonrozsival opened this issue Jul 27, 2022 · 5 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Milestone

Comments

@simonrozsival
Copy link
Member

Description

When I'm running the browser sample, occasionally the browser tab crashes reporting "Out of Memory".

It appears that the setup_proxy_console (debug.ts) called from the dotnet-crypto-worker.js modifies the console functions to send all logs over a websocket. The crash that I ran into occurs when the websocket connection fails and the onerror event logs this failure. This leads to an indirect infinite recursion bertween the local function send and the console.log replacement function and the browser tab runs out of memory in just a few seconds (the worker allocates over 3.5 GB of memory).

It seems this bug was introduced in #71693

Reproduction Steps

  1. Build dotnet for Browser .\build.cmd mono+libs+packs -os Browser -c Release
  2. Build the browser sample: .\dotnet.cmd build src\mono\sample\wasm\browser
  3. Serve the output directory: .\dotnet.cmd serve -d:src\mono\sample\wasm\browser\bin\Release\AppBundle -h "Cross-Origin-Opener-Policy:same-origin" -h "Cross-Origin-Embedder-Policy:require-corp" -o -p:8000
  4. Open http://localhost:8000 in Edge or Chrome
  5. Open dev tools and refresh the page until you see WebSocket connection to 'ws://localhost:8000/console' failed in the console. It doesn't happen every time but it happens very often so you might need to refresh the page several times.
  6. Switch to the Memory tab in the dev tools and watch the heap size of dotnet-crypto-worker.js grow rapidly
  7. The browser tab will crash in 30-60 seconds

Expected behavior

The browser tab doesn't crash.

Actual behavior

The browser tab crashes.

Regression?

No response

Known Workarounds

No response

Configuration

Other information

No response

@simonrozsival simonrozsival added the arch-wasm WebAssembly architecture label Jul 27, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jul 27, 2022
@ghost
Copy link

ghost commented Jul 27, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When I'm running the browser sample, occasionally the browser tab crashes reporting "Out of Memory".

It appears that the setup_proxy_console (debug.ts) called from the dotnet-crypto-worker.js modifies the console functions to send all logs over a websocket. The crash that I ran into occurs when the websocket connection fails and the onerror event logs this failure. This leads to an indirect infinite recursion bertween the local function send and the console.log replacement function and the browser tab runs out of memory in just a few seconds (the worker allocates over 3.5 GB of memory).

It seems this bug was introduced in #71693

Reproduction Steps

  1. Build dotnet for Browser .\build.cmd mono+libs+packs -os Browser -c Release
  2. Build the browser sample: .\dotnet.cmd build src\mono\sample\wasm\browser
  3. Serve the output directory: .\dotnet.cmd serve -d:src\mono\sample\wasm\browser\bin\Release\AppBundle -h "Cross-Origin-Opener-Policy:same-origin" -h "Cross-Origin-Embedder-Policy:require-corp" -o -p:8000
  4. Open http://localhost:8000 in Edge or Chrome
  5. Open dev tools and refresh the page until you see WebSocket connection to 'ws://localhost:8000/console' failed in the console. It doesn't happen every time but it happens very often so you might need to refresh the page several times.
  6. Switch to the Memory tab in the dev tools and watch the heap size of dotnet-crypto-worker.js grow rapidly
  7. The browser tab will crash in 30-60 seconds

Expected behavior

The browser tab doesn't crash.

Actual behavior

The browser tab crashes.

Regression?

No response

Known Workarounds

No response

Configuration

Other information

No response

Author: simonrozsival
Assignees: -
Labels:

arch-wasm

Milestone: -

@lewing lewing added area-VM-meta-mono and removed untriaged New issue has not been triaged by the area owner labels Jul 27, 2022
@lewing lewing added this to the 7.0.0 milestone Jul 27, 2022
@pavelsavara
Copy link
Member

I think that setup_proxy_console doesn't belong to production code.
It could be in separate ES6 module dynamically loaded by dotnet.js only when there is some configuration for it.
For sure should not send console log to localhost on random production machine without explicit config for it.

@pavelsavara pavelsavara self-assigned this Jul 28, 2022
@radical radical removed their assignment Jul 28, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 29, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 5, 2022
@simonrozsival
Copy link
Member Author

@pavelsavara your PR #73468 fixed the issue so I'm closing the issue

@pavelsavara
Copy link
Member

good, thanks.
I have follow up which fixes the deployment to Blazor, still work in progress.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono
Projects
None yet
Development

No branches or pull requests

4 participants