dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

WasmEnableThreads incrementalism is broken #98502

Open SteveSandersonMS opened 9 months ago

SteveSandersonMS commented 9 months ago

Description

If you have a Blazor WebAssembly app with WasmEnableThreads=true, and then change it to false, the build output is corrupted and won't work until you delete bin/obj and build again.

Reproduction Steps

  1. Create a .NET 9 Blazor WebAssembly app with WasmEnableThreads=true. Make sure you set this flag before you build for the first time.
  2. Run it from VS with Ctrl+F5 and observe it working
  3. Change WasmEnableThreads to false
  4. Ctrl+F5 again

Expected behavior

It should work in single-threaded mode

Actual behavior

It fails with:

image

Regression?

No

Known Workarounds

Delete bin & obj folders

(which unfortunately is not something we can expect developers to do in reality)

Configuration

.NET 9 WebAssembly

Other information

No response

SteveSandersonMS commented 9 months ago

cc @lewing @pavelsavara

SteveSandersonMS commented 9 months ago

Note that a similar problem also happens when switching WasmEnableThreads from false to true without deleting bin/obj, which is even more confusing because then you will likely think that further config is required to enable threading, when it isn't.

ghost commented 9 months ago

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

Issue Details
### Description If you have a Blazor WebAssembly app with WasmEnableThreads=true, and then change it to false, the build output is corrupted and won't work until you delete bin/obj and build again. ### Reproduction Steps 1. Create a .NET 9 Blazor WebAssembly app with WasmEnableThreads=true. Make sure you set this flag *before* you build for the first time. 2. Run it from VS with Ctrl+F5 and observe it working 3. Change WasmEnableThreads to false 4. Ctrl+F5 again ### Expected behavior It should work in single-threaded mode ### Actual behavior It fails with: ![image](https://github.com/dotnet/runtime/assets/1101362/6da197e1-4ef5-45cd-84e1-2a23ba4a43fb) ### Regression? No ### Known Workarounds Delete bin/obj (which unfortunately is not something we can expect developers to do in reality) ### Configuration .NET 9 WebAssembly ### Other information _No response_
Author: SteveSandersonMS
Assignees: -
Labels: `arch-wasm`, `untriaged`, `area-Build-mono`, `os-browser`
Milestone: -
lewing commented 9 months ago

Thanks for pointing this out, we'll make sure it gets resolved

maraf commented 9 months ago

The problem is with conversion to webcil format. The ConvertDllsToWebCil compares only file timestamp, but not if the original location has changed https://github.com/dotnet/runtime/blob/c768315c5698391f45a6a47d56fec4ba3df59fb8/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs#L70