Skip to content

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

Closed
@simonrozsival

Description

@simonrozsival

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions