runtime: [browser][mt] Running any Thread for longer than 5000 ms crashes runtime (Blazor)

Description

Spawning any long-running Task or Thread from the main thread for longer than 5000 ms kills application and runtime when using Blazor. Screenshot 2023-05-29 182353

Reproduction Steps

  1. Create empty Blazor app and use current main build of runtime in project file
  2. Use Task.Run, Thread.Start or async/await anywhere in the app with a long-running task (importantly, NOT Task.Yield or Task.Delay)
  3. Observe the error and runtime crash.

Expected behavior

I should be able to start a task from anywhere on the main thread using Task.Run in a Blazor app and not have the runtime crash after 5000ms

Actual behavior

Runtime crashes with error (screenshot above)

Regression?

This previously worked perfectly on the official release build of .NET 8 Preview 4.

Known Workarounds

None

Configuration

No response

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (14 by maintainers)

Most upvoted comments

@lambdageek Of course. It is definitely a compute intensive task in .NET land. No interop is happening inside of it.

@IsaMorphic Can you say a bit more about what’s in the body of the long-running task? Is it compute-intensive? doing a synchronous call to JS that takes longer than 5 seconds? calling some native wasm code (like C code)?

In principle if the long-running task is just a compute loop in C# it should be trying to safepoint at backward branches in the loops… unless we’re failing to emit the safepointing opcodes for some reason…