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

fix: Restore threading tests #899

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build/ci/stage-build-linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ jobs:
"$(build.sourcesdirectory)/src/Uno.Wasm.Threads/bin/Release/net9.0/publish/wwwroot" \
"$(build.sourcesdirectory)/src/Uno.Wasm.Threading.UITests" "http://localhost:8000/"
displayName: Threading UI Tests
condition: eq( variables['THREAD_TESTING'], 'true' )
env:
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"

Expand All @@ -82,7 +81,6 @@ jobs:
"$(build.sourcesdirectory)/src/Uno.Wasm.Threads.Aot/bin/Release/net9.0/publish/wwwroot" \
"$(build.sourcesdirectory)/src/Uno.Wasm.Threading.UITests" "http://localhost:8000/"
displayName: Threading AOT UI Tests
condition: eq( variables['THREAD_TESTING'], 'true' )
env:
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"

Expand Down
2 changes: 0 additions & 2 deletions build/ci/stage-build-windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ jobs:
"http://localhost:8000/"

displayName: Threading Tests
condition: eq( variables['THREAD_TESTING'], 'true' )
env:
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"

Expand All @@ -258,7 +257,6 @@ jobs:
"$(build.sourcesdirectory)\src\Uno.Wasm.Threading.UITests" `
"http://localhost:8000/"
displayName: Threading AOT Tests
condition: eq( variables['THREAD_TESTING'], 'true' )
env:
BUILD_SOURCESDIRECTORY: "$(build.sourcesdirectory)"

Expand Down
19 changes: 8 additions & 11 deletions src/Uno.Wasm.Threads.Shared/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public static class Program
private static List<string> _messages = new List<string>();
private static bool _mainThreadInvoked = false;
private static Timer _timer;
private static SynchronizationContext _jsContext = SynchronizationContext.Current;

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}");
Console.WriteLine($"SynchronizationContext: {_jsContext}");

Runtime.InvokeJS("Interop.appendResult('Startup')");

Expand Down Expand Up @@ -92,34 +94,29 @@ void DoWork(string name)

if ((i % 2000) == 0)
{
WebAssembly.JSInterop.InternalCalls.InvokeOnMainThread();
Console.WriteLine("InvokeOnMainThread1");
_jsContext.Post(_ => MainThreadCallback(), null);
}
}
}

#pragma warning disable CA1416 // Validate platform compatibility
new Thread(_ =>
{
Console.WriteLine($"Starting thread [tid:{Thread.CurrentThread.ManagedThreadId}]");

WebAssembly.JSInterop.InternalCalls.InvokeOnMainThread();
_jsContext.Post(_ => MainThreadCallback(), null);
Console.WriteLine("InvokeOnMainThread2");

DoWork("thread1");
tcs.TrySetResult(true);
Console.WriteLine($"Stopping thread [tid:{Thread.CurrentThread.ManagedThreadId}]");
}).Start();
#pragma warning restore CA1416 // Validate platform compatibility

await tcs.Task;

_event.Set();
}
}
}

namespace WebAssembly.JSInterop
{
public static class InternalCalls
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void InvokeOnMainThread();
}
}
7 changes: 0 additions & 7 deletions src/Uno.Wasm.Threads.Shared/WasmScripts/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ var Interop = {
parent.appendChild(txt, parent.lastChild);
}
};

var DotNet = {
invokeOnMainThread: function (str) {
let getApplyUpdateCapabilitiesMethod = BINDING.bind_static_method("[Uno.Wasm.Threads] Uno.Wasm.Sample.Program:MainThreadCallback");
getApplyUpdateCapabilitiesMethod();
}
}
Loading