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-mt] JSImport and JSExport marshaler infrastructure is not initialized on web worker threads #77287

Closed
thaystg opened this issue Oct 20, 2022 · 2 comments

Comments

@thaystg
Copy link
Member

thaystg commented Oct 20, 2022

Assert failed: ERR41: Unknown converter for type 13

To reproduce:

  • build.cmd mono+libs -os browser /p:WasmEnableThreads=true

  • dotnet test src/mono/wasm/debugger/DebuggerTestSuite --filter DebuggerTests.MiscTests.InspectTaskAtLocals -e RuntimeConfiguration=Debug -e Configuration=Debug -e DebuggerHost=chrome -e WasmEnableThreads=true (only to build)

  • Go to folder and run:

cd \artifacts\bin\debugger-test\Debug\AppBundle

..\..\..\..\..\dotnet.cmd serve  -h "Cross-Origin-Opener-Policy:same-origin" -h "Cross-Origin-Embedder-Policy:require-corp" -p 9400
Open on chrome: http://localhost:9400/debugger-driver.html
  • Open Inspector
  • Go to Watch and run this command: invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask')

IMPORTANT: This is not using anything related to our debugger, because we are not using the remote debugging and the browser debug proxy.

As discussed with Pavel this is expected to not work.

This is the C# code executed:

public class WeatherForecast
{
    public DateTime Date { get; set; }

    public int TemperatureC { get; set; }

    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

    public string Summary { get; set; }
}

public class InspectTask
{
    public static async System.Threading.Tasks.Task RunInspectTask()
    {
        WeatherForecast[] forecasts = null;
        var httpClient = new System.Net.Http.HttpClient();
        var getJsonTask = httpClient.GetFromJsonAsync<WeatherForecast[]>("http://localhost:9400/weather.json");
        try
        {
            await getJsonTask.ContinueWith(t =>
                {
                    int a = 10;
                    Console.WriteLine(a);
                    if (t.IsCompletedSuccessfully)
                        forecasts = t.Result;

                    if (t.IsFaulted)
                        throw t.Exception!;
                });
        }
        catch (Exception ex)
        {
            Console.WriteLine($"error {ex}");
            return;
        }
    }
}
@ghost
Copy link

ghost commented Oct 20, 2022

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

Issue Details

To reproduce:

  • build.cmd mono+libs -os browser /p:WasmEnableThreads=true

  • dotnet test src/mono/wasm/debugger/DebuggerTestSuite --filter DebuggerTests.MiscTests.InspectTaskAtLocals -e RuntimeConfiguration=Debug -e Configuration=Debug -e DebuggerHost=chrome -e WasmEnableThreads=true (only to build)

  • Go to folder and run:

cd \artifacts\bin\debugger-test\Debug\AppBundle

..\..\..\..\..\dotnet.cmd serve  -h "Cross-Origin-Opener-Policy:same-origin" -h "Cross-Origin-Embedder-Policy:require-corp" -p 9400
Open on chrome: http://localhost:9400/debugger-driver.html
  • Open Inspector
  • Go to Watch and run this command: invoke_static_method_async('[debugger-test] InspectTask:RunInspectTask')

IMPORTANT: This is not using anything related to our debugger, because we are not using the remote debugging and the browser debug proxy.

As discussed with Pavel this is expected to not work.

This is the C# code executed:

public class WeatherForecast
{
    public DateTime Date { get; set; }

    public int TemperatureC { get; set; }

    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

    public string Summary { get; set; }
}

public class InspectTask
{
    public static async System.Threading.Tasks.Task RunInspectTask()
    {
        WeatherForecast[] forecasts = null;
        var httpClient = new System.Net.Http.HttpClient();
        var getJsonTask = httpClient.GetFromJsonAsync<WeatherForecast[]>("http://localhost:9400/weather.json");
        try
        {
            await getJsonTask.ContinueWith(t =>
                {
                    int a = 10;
                    Console.WriteLine(a);
                    if (t.IsCompletedSuccessfully)
                        forecasts = t.Result;

                    if (t.IsFaulted)
                        throw t.Exception!;
                });
        }
        catch (Exception ex)
        {
            Console.WriteLine($"error {ex}");
            return;
        }
    }
}
Author: thaystg
Assignees: pavelsavara
Labels:

arch-wasm, feature-request, area-System.Runtime.InteropServices.JavaScript

Milestone: 8.0.0

@pavelsavara pavelsavara changed the title [wasm-mt] Assert failed: ERR41: Unknown converter for type 13 [wasm-mt] JSImport and JSExport is not initialized on web worker threads Oct 27, 2022
@pavelsavara pavelsavara changed the title [wasm-mt] JSImport and JSExport is not initialized on web worker threads [wasm-mt] JSImport and JSExport marshaler infrastructure is not initialized on web worker threads Oct 27, 2022
@pavelsavara
Copy link
Member

invoke_static_method is legacy JS interop. It is not supported on any other than main thread. Here it's used by the test code.
The JSExport/JSImport could be used on threads which were created with WebWorker API, but that's out of scope for Net8.

@thaystg could you please describe why the unit test is sending the commands to any other than main thread ? Is that intentional ? Or am I confused about it ?

@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants