-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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][Threading] Task.Delay only continues after a GC #70571
Comments
Tagging subscribers to this area: @mangod9 Issue DetailsDescriptionGiven a Wasm Threads enabled runtime, using Task.Delay waits for the next GC to continue. Reproduction StepsGiven a Wasm Threads enabled runtime, and the following code: static void Main()
{
var runtimeMode = Environment.GetEnvironmentVariable("UNO_BOOTSTRAP_MONO_RUNTIME_MODE");
Console.WriteLine($"Runtime Version: " + RuntimeInformation.FrameworkDescription);
Console.WriteLine($"Runtime Mode: " + runtimeMode);
Console.WriteLine($"TID: {Thread.CurrentThread.ManagedThreadId}");
Bug01();
}
private static void Bug01()
{
Timer t = new Timer(_ =>
{
Log($"Before GC");
GC.Collect();
Log($"After GC");
});
t.Change(5000, 0);
Log($"-> Bug01");
Task.Run(async () =>
{
var sw = Stopwatch.StartNew();
Log($"Before 2000ms delay");
await Task.Delay(2000);
Log($"After delay {sw.ElapsedMilliseconds}");
});
Log($"<- Bug01");
void Log(string message) => Console.WriteLine($"[TID:{Thread.CurrentThread.ManagedThreadId}] {message}");
} Shows the following Expected behaviorThe Async method continues after about 2 seconds, not when the GC has been invoked. Actual behavior
Regression?no Known Workaroundsnone ConfigurationOther informationNo response
|
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionGiven a Wasm Threads enabled runtime, using Task.Delay waits for the next GC to continue. Reproduction StepsGiven a Wasm Threads enabled runtime, and the following code: static void Main()
{
Console.WriteLine($"Runtime Version: " + RuntimeInformation.FrameworkDescription);
Console.WriteLine($"Runtime Mode: " + runtimeMode);
Console.WriteLine($"TID: {Thread.CurrentThread.ManagedThreadId}");
Bug01();
}
private static void Bug01()
{
Timer t = new Timer(_ =>
{
Log($"Before GC");
GC.Collect();
Log($"After GC");
});
t.Change(5000, 0);
Log($"-> Bug01");
Task.Run(async () =>
{
var sw = Stopwatch.StartNew();
Log($"Before 2000ms delay");
await Task.Delay(2000);
Log($"After delay {sw.ElapsedMilliseconds}");
});
Log($"<- Bug01");
void Log(string message) => Console.WriteLine($"[TID:{Thread.CurrentThread.ManagedThreadId}] {message}");
} Shows the following Expected behaviorThe Async method continues after about 2 seconds, not when the GC has been invoked. Actual behavior
Regression?no Known Workaroundsnone ConfigurationOther informationNo response
|
Fixed by #70863 |
Description
Given a Wasm Threads enabled runtime, using Task.Delay waits for the next GC to continue.
Reproduction Steps
Given a Wasm Threads enabled runtime, and the following code:
Shows the following
Expected behavior
The Async method continues after about 2 seconds, not when the GC has been invoked.
Actual behavior
Regression?
no
Known Workarounds
none
Configuration
be4d292
Other information
No response
The text was updated successfully, but these errors were encountered: