Skip to content

feat: Add WebWorker support#1056

Draft
jeromelaban wants to merge 27 commits intomainfrom
dev/jela/webworker
Draft

feat: Add WebWorker support#1056
jeromelaban wants to merge 27 commits intomainfrom
dev/jela/webworker

Conversation

@jeromelaban
Copy link
Copy Markdown
Member

No description provided.

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copilot AI review requested due to automatic review settings March 18, 2026 01:33
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new WebWorker shell mode to Uno.Wasm.Bootstrap, including generated worker bootstrap output, host-project integration to publish worker assets under a sub-path, plus end-to-end validation (Puppeteer) and documentation.

Changes:

  • Add ShellMode.WebWorker with worker bootstrap generation (worker.js + minimal index.html) and related build pipeline updates.
  • Add host integration MSBuild targets to build/publish a worker project and place its assets under wwwroot/_worker/.
  • Add samples/tests/docs/CI to validate WebWorker runtime initialization and messaging.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/Uno.Wasm.Tests.WebWorker/validate-webworker.js Puppeteer-based runtime validator for host+worker messaging/results.
src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Publish host app, validate outputs, serve with COOP/COEP, run Puppeteer validation.
src/Uno.Wasm.Tests.WebWorker/package.json NPM deps for the WebWorker validation harness.
src/Uno.Wasm.Tests.WebWorker/package-lock.json Locked NPM dependency graph for the validation harness.
src/Uno.Wasm.Tests.WebWorker.Host/Uno.Wasm.Tests.WebWorker.Host.csproj Host app configured to publish/import the worker under _worker/.
src/Uno.Wasm.Tests.WebWorker.Host/Program.cs Host creates Worker('./_worker/worker.js') and displays worker messages.
src/Uno.Wasm.Tests.WebWorker.App/Uno.Wasm.Tests.WebWorker.App.csproj Worker-mode app project (WasmShellMode=WebWorker).
src/Uno.Wasm.Tests.WebWorker.App/Program.cs Worker posts a dotnet-ready message via postMessage.
src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj RayTracer host publishes an accompanying worker project under _worker/.
src/Uno.Wasm.Sample.RayTracer.Worker/Uno.Wasm.Sample.RayTracer.Worker.csproj New RayTracer worker project running benchmark inside WebWorker mode.
src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs Worker executes benchmark and posts logs/result image back to host.
src/Uno.Wasm.Sample.RayTracer.Shared/WasmScripts/image.js Host page JS updated to start the worker and render its output side-by-side.
src/Uno.Wasm.Bootstrap/tsconfig.worker.json TS build for worker bootstrap output (uno-worker-bootstrap.js).
src/Uno.Wasm.Bootstrap/tsconfig.json Excludes worker bootstrap TS from main browser bootstrap compilation.
src/Uno.Wasm.Bootstrap/ts/WorkerEntrypoint.ts Worker bundle entrypoint invoking WorkerBootstrapper.bootstrap().
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Worker-side .NET runtime bootstrap + profiler messaging helpers.
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/EmscriptenMemoryProfilerSupport.ts Expose JSON builders usable from worker context (no DOM).
src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Add worker filename property + host/worker publish integration targets.
src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj Include worker tsconfig; embed generated JS with updated logical name.
src/Uno.Wasm.Bootstrap/ShellTask.cs Generate worker.js and minimal host index.html for WebWorker mode; skip SW.
src/Uno.Wasm.Bootstrap/ShellMode.cs Add WebWorker enum value.
specs/003-webworker-mode/spec.md Feature spec for WebWorker shell mode.
specs/003-webworker-mode/progress.md Progress log for the feature.
doc/toc.yml Adds docs navigation entry for WebWorker mode.
doc/features-webworker-mode.md User-facing documentation for configuring/using WebWorker mode and profiling.
build/ci/stage-build-linux-tests.yml Adds a CI job step to run the WebWorker end-to-end test.
.gitignore Ignores a local Claude settings file.
Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
Comment thread src/Uno.Wasm.Tests.WebWorker/validate-webworker.js
Comment thread specs/003-webworker-mode/progress.md Outdated
Comment thread src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs Outdated
Comment thread src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Outdated
Comment thread src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Outdated
Comment thread src/Uno.Wasm.Bootstrap/ShellTask.cs
Comment thread src/Uno.Wasm.Bootstrap/ShellTask.cs
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copilot AI review requested due to automatic review settings March 18, 2026 02:41
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new WebWorker shell mode to Uno.Wasm.Bootstrap, enabling .NET WASM apps to boot inside a classic Web Worker, plus host-project integration to publish a worker app under a subfolder (e.g. wwwroot/_worker/) with its own _framework/.

Changes:

  • Added a worker bootstrap pipeline (TS worker bootstrapper + C# generation of worker.js/minimal index.html) and new MSBuild properties/targets for host+worker publishing.
  • Added end-to-end validation via a new WebWorker test app/host app and Puppeteer-based CI test script.
  • Updated RayTracer sample to run the benchmark in both main thread and a Web Worker.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Uno.Wasm.Tests.WebWorker/validate-webworker.js Puppeteer runtime validation for host+worker output
src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Build/publish + serve + run Puppeteer validation script
src/Uno.Wasm.Tests.WebWorker/package.json Adds Puppeteer dependency for the WebWorker test harness
src/Uno.Wasm.Tests.WebWorker/package-lock.json Locks Puppeteer and transitive dependencies
src/Uno.Wasm.Tests.WebWorker.Host/Uno.Wasm.Tests.WebWorker.Host.csproj Host project wiring for worker publish integration properties
src/Uno.Wasm.Tests.WebWorker.Host/Program.cs Host creates worker and renders received messages into DOM
src/Uno.Wasm.Tests.WebWorker.App/Uno.Wasm.Tests.WebWorker.App.csproj Worker-mode test app project definition
src/Uno.Wasm.Tests.WebWorker.App/Program.cs Worker posts a “dotnet-ready” message to host
src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj Adds worker project publish integration to sample host
src/Uno.Wasm.Sample.RayTracer.Worker/Uno.Wasm.Sample.RayTracer.Worker.csproj New worker-mode project for RayTracer benchmark
src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs Runs benchmark in worker and posts results/logs to host
src/Uno.Wasm.Sample.RayTracer.Shared/WasmScripts/image.js Host-side UI and worker message handling for worker-rendered image
src/Uno.Wasm.Bootstrap/tsconfig.worker.json New TS build for worker bootstrap output bundle
src/Uno.Wasm.Bootstrap/tsconfig.json Excludes worker TS sources from main bootstrap bundle
src/Uno.Wasm.Bootstrap/ts/WorkerEntrypoint.ts Worker entrypoint calling WorkerBootstrapper.bootstrap()
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Worker runtime initialization + config loading + profiler hooks
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/EmscriptenMemoryProfilerSupport.ts Adds worker-friendly JSON builders for profiler export
src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Adds WebWorker MSBuild properties, hot reload/service-worker skips, and host integration targets
src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj Includes tsconfig.worker.json and adjusts embedded resource naming
src/Uno.Wasm.Bootstrap/ShellTask.cs Generates worker.js + minimal host index.html; skips service worker in WebWorker mode
src/Uno.Wasm.Bootstrap/ShellMode.cs Adds WebWorker enum value
specs/003-webworker-mode/spec.md Feature spec for WebWorker shell mode
specs/003-webworker-mode/progress.md Progress/notes and known limitations for the implementation
doc/toc.yml Adds WebWorker mode docs to TOC
doc/features-webworker-mode.md User-facing documentation for WebWorker mode
build/ci/stage-build-linux-tests.yml Adds WebWorker CI validation step and artifact publishing
.gitignore Ignores .claude/settings.local.json
Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Outdated
Comment thread src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs
Comment thread doc/features-webworker-mode.md Outdated
Comment thread src/Uno.Wasm.Bootstrap/ShellTask.cs Outdated
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts
Comment thread src/Uno.Wasm.Tests.WebWorker/validate-webworker.js
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copilot AI review requested due to automatic review settings March 18, 2026 12:32
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new WebWorker shell mode to Uno.Wasm.Bootstrap, including build-time host↔worker integration, worker bootstrap/runtime initialization, and an end-to-end CI validation harness.

Changes:

  • Introduce ShellMode.WebWorker and generate a worker bootstrap script (worker.js) + minimal host index.html.
  • Add MSBuild targets to build/publish a worker project and import its static web assets + _framework/ into a host app under WasmShellWorkerBasePath.
  • Add docs/specs, a RayTracer worker sample integration, and a Puppeteer-based CI test.

Reviewed changes

Copilot reviewed 27 out of 29 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Uno.Wasm.Tests.WebWorker/validate-webworker.js Puppeteer-based runtime validation for host+worker.
src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Linux test runner that publishes host, serves output, and runs validation.
src/Uno.Wasm.Tests.WebWorker/package.json Node dependencies for the WebWorker test harness.
src/Uno.Wasm.Tests.WebWorker/package-lock.json Lockfile for Puppeteer and transitive dependencies.
src/Uno.Wasm.Tests.WebWorker.Host/Uno.Wasm.Tests.WebWorker.Host.csproj Host project wiring for worker integration properties.
src/Uno.Wasm.Tests.WebWorker.Host/Program.cs Host-side worker creation + message handling.
src/Uno.Wasm.Tests.WebWorker.App/Uno.Wasm.Tests.WebWorker.App.csproj Worker-mode test app project definition.
src/Uno.Wasm.Tests.WebWorker.App/Program.cs Worker-side “dotnet-ready” postMessage smoke signal.
src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj Enables publishing a worker alongside the RayTracer host sample.
src/Uno.Wasm.Sample.RayTracer.Worker/Uno.Wasm.Sample.RayTracer.Worker.csproj New worker-mode RayTracer project.
src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs Worker-side raytracer execution + postMessage result transport.
src/Uno.Wasm.Sample.RayTracer.Shared/WasmScripts/image.js Host UI updates to render both main-thread and worker results.
src/Uno.Wasm.Bootstrap/tsconfig.worker.json TS build config for worker bootstrap bundle output.
src/Uno.Wasm.Bootstrap/tsconfig.json Excludes worker-only TS sources from the main TS build.
src/Uno.Wasm.Bootstrap/ts/WorkerEntrypoint.ts Worker bootstrap entrypoint invoking WorkerBootstrapper.
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts New worker runtime bootstrapper (config load, dotnet init, profiling hooks).
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/EmscriptenMemoryProfilerSupport.ts Adds worker-friendly JSON builders (no DOM dependency).
src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets MSBuild integration for worker filename + host import/publish of worker assets.
src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj Includes worker TS config and adjusts embedded resource naming.
src/Uno.Wasm.Bootstrap/ShellTask.cs Generates worker JS + disables service worker for WebWorker mode.
src/Uno.Wasm.Bootstrap/ShellMode.cs Adds WebWorker to the shell mode enum.
specs/003-webworker-mode/spec.md Feature spec for WebWorker shell mode.
specs/003-webworker-mode/progress.md Implementation progress and known limitations tracking.
doc/toc.yml Adds docs entry for WebWorker mode.
doc/features-webworker-mode.md User-facing documentation for WebWorker mode and host integration.
build/scripts/validate-dotnetjs-fingerprint.sh Avoids selecting worker uno-config.js when validating host output.
build/ci/stage-build-linux-tests.yml Adds a Linux CI job step for the WebWorker end-to-end test.
build/ci/cspell.json Adds WebWorker-related terms to the spelling dictionary.
.gitignore Ignores a local Claude settings file.
Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
Comment thread src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Outdated
Comment thread src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Outdated
Comment thread src/Uno.Wasm.Tests.WebWorker/package.json Outdated
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new WebWorker shell mode to Uno.Wasm.Bootstrap, enabling publishing a worker bootstrap (worker.js) and integrating a worker project into a host app under a configurable base path (default _worker/). This includes build/publish pipeline changes, a TS worker bootstrapper, new test harness + CI coverage, and sample updates.

Changes:

  • Add ShellMode.WebWorker with worker bootstrap generation and host↔worker publish integration via MSBuild (WasmShellWebWorkerProject, _UnoBuildAndImportWebWorkerAssets, _UnoPublishWebWorkerFramework).
  • Add worker runtime bootstrapper (TypeScript) with profiler command plumbing; add log-profiler flush shim for .NET 10+ WASM.
  • Add docs/specs plus a new Puppeteer-based CI test and update RayTracer sample to demonstrate host+worker.

Reviewed changes

Copilot reviewed 30 out of 32 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Uno.Wasm.Tests.WebWorker/validate-webworker.js Puppeteer runtime validator for host+worker behavior.
src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Publishes host, validates outputs, serves with COOP/COEP, runs Puppeteer validation.
src/Uno.Wasm.Tests.WebWorker/package.json NPM deps for the WebWorker test harness.
src/Uno.Wasm.Tests.WebWorker/package-lock.json Lockfile for the WebWorker test harness dependencies.
src/Uno.Wasm.Tests.WebWorker.Host/Uno.Wasm.Tests.WebWorker.Host.csproj Host test project that embeds a worker via MSBuild properties.
src/Uno.Wasm.Tests.WebWorker.Host/Program.cs Host JS bootstrap to create worker and display worker messages.
src/Uno.Wasm.Tests.WebWorker.App/Uno.Wasm.Tests.WebWorker.App.csproj Worker test project using WasmShellMode=WebWorker.
src/Uno.Wasm.Tests.WebWorker.App/Program.cs Worker posts a readiness message back to host.
src/Uno.Wasm.Sample.RayTracer/Uno.Wasm.Sample.RayTracer.csproj Integrates a worker companion project into the RayTracer sample.
src/Uno.Wasm.Sample.RayTracer.Worker/Uno.Wasm.Sample.RayTracer.Worker.csproj New WebWorker-mode RayTracer worker project.
src/Uno.Wasm.Sample.RayTracer.Worker/Program.cs Worker-side benchmark execution + result messaging.
src/Uno.Wasm.Sample.RayTracer.Shared/WasmScripts/image.js UI updated to show main-thread vs worker rendering and receive worker messages.
src/Uno.Wasm.LogProfiler/profiler_flush_wasm.c Native shim to restore/bridge log-profiler flushing on .NET 10+ WASM.
src/Uno.Wasm.LogProfiler/LogProfilerSupport.cs Expose profiler helpers via JSExport for worker access.
src/Uno.Wasm.Bootstrap/tsconfig.worker.json New TS build for worker bootstrap output bundle.
src/Uno.Wasm.Bootstrap/tsconfig.json Excludes worker TS entrypoints from the main bundle.
src/Uno.Wasm.Bootstrap/ts/WorkerEntrypoint.ts Worker bundle entrypoint calling worker bootstrap.
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Worker bootstrap implementation: config load, runtime init, profiler plumbing.
src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/EmscriptenMemoryProfilerSupport.ts Adds worker-friendly JSON builders (no DOM dependency).
src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets Adds worker asset import/publish targets and worker filename plumbing.
src/Uno.Wasm.Bootstrap/Uno.Wasm.Bootstrap.csproj Packs worker TS config and copies/ships native profiler shim.
src/Uno.Wasm.Bootstrap/ShellTask.cs Generates worker bootstrap script + standalone host page; skips service worker for WebWorker.
src/Uno.Wasm.Bootstrap/ShellMode.cs Adds WebWorker enum value.
specs/003-webworker-mode/spec.md Feature specification for WebWorker mode.
specs/003-webworker-mode/progress.md Progress/notes for the WebWorker mode workstream.
doc/toc.yml Adds documentation entry for WebWorker mode.
doc/features-webworker-mode.md User-facing documentation for configuring/using WebWorker mode.
build/scripts/validate-dotnetjs-fingerprint.sh Avoids selecting worker uno-config.js when validating host fingerprint.
build/scripts/validate-boot-config.sh Avoids selecting worker uno-config.js when validating host boot config.
build/ci/stage-build-linux-tests.yml Adds WebWorker CI job step and publishes artifacts.
build/ci/cspell.json Adds WebWorker-related terms to spelling whitelist.
.gitignore Ignores .claude/settings.local.json.
Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread specs/003-webworker-mode/spec.md
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
Comment thread specs/003-webworker-mode/spec.md Outdated
Comment thread specs/003-webworker-mode/spec.md
Comment thread specs/003-webworker-mode/progress.md
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts
Comment thread src/Uno.Wasm.Tests.WebWorker/test-webworker.sh
Comment thread specs/003-webworker-mode/spec.md
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copilot AI review requested due to automatic review settings March 19, 2026 20:34
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/LogProfilerSupport.ts
Comment thread src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts Outdated
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported
Comments suppressed due to low confidence (4)

src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts:306

  • handleAotProfilerSave calls dotnetRuntime.getAssemblyExports(...) without awaiting it. In this repo getAssemblyExports is async/Promise-based, so exports.Uno... will be undefined and the AOT profile save will fail. Make this method async and await the exports lookup (and update the call sites accordingly).
		private static handleAotProfilerSave(dotnetRuntime: any): void {
			try {
				const getExports = dotnetRuntime.getAssemblyExports;
				if (!getExports) {
					throw 'getAssemblyExports not available';
				}

				const exports = getExports("Uno.Wasm.AotProfiler");
				exports.Uno.AotProfilerSupport.StopProfile();

src/Uno.Wasm.Bootstrap/ts/Uno/WebAssembly/WorkerBootstrapper.ts:35

  • The worker DotnetModuleConfig here doesn’t specify exports (e.g. FS, IDBFS). Later handleLogProfilerSave depends on dotnetRuntime.Module.FS being available; without explicitly exporting it (as the main Bootstrapper does), log-profile saving can fail with Module.FS not available. Consider adding an exports list mirroring Bootstrapper.asDotnetConfig().
				const dotnetRuntime = await dotnetModule.default(
					(_context: any) => {
						return {
							disableDotnet6Compatibility: false,
							configSrc: <string>undefined,
							baseUrl: config.uno_app_base,
							mainScriptPath: '_framework/' + config.dotnet_js_filename,
							onConfigLoaded: (monoConfig: any) => {
								WorkerBootstrapper.configLoaded(config, monoConfig);
							},
							onDotnetReady: () => { },
						};

specs/003-webworker-mode/spec.md:170

  • This section says the worker config loader replaces let config with self.config, but the implementation actually replaces let config with var config and returns it from the Function body. Please update the spec to match the implemented transform (or update the implementation if self.config is required).
### Config Loading via fetch+eval

The `uno-config.js` file uses ES module `export` syntax, which is incompatible with `importScripts()` in classic workers. The worker script fetches the config via `fetch()`, strips the `export` statement, replaces `let config` with `self.config` to escape the `new Function()` scope, and evaluates it.

specs/003-webworker-mode/progress.md:60

  • Known Limitations mentions _UnoPublishWebWorkerFramework “hardcodes net10.0” for the worker publish output path, but the MSBuild target now queries the worker project’s TargetFramework via _UnoGetTargetFramework. Update this section to avoid stale/incorrect guidance.
2. **`_framework/` files come from worker publish output**: The worker's `_framework/` files aren't in the SDK's build manifest (they're generated by the WASM publish pipeline). The `_UnoPublishWebWorkerFramework` target publishes the worker and copies `_framework/` into the host's `wwwroot/_worker/_framework/`.

3. **Hardcoded TFM path**: The `_UnoPublishWebWorkerFramework` target currently hardcodes `net10.0` in the worker's publish output path. This should be derived from the worker project's `TargetFramework`.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Uno.Wasm.Tests.WebWorker/package.json
Comment thread specs/003-webworker-mode/spec.md Outdated
Comment thread src/Uno.Wasm.Tests.WebWorker/test-webworker.sh Outdated
Comment thread specs/003-webworker-mode/progress.md Outdated
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copilot AI review requested due to automatic review settings March 20, 2026 01:38
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +45
imgData.data[i + 0] = raw.charCodeAt(i + 2); // R from B
imgData.data[i + 1] = raw.charCodeAt(i + 1); // G
imgData.data[i + 2] = raw.charCodeAt(i + 0); // B from R
imgData.data[i + 3] = raw.charCodeAt(i + 3); // A
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The per-channel comments in the worker image conversion are misleading: raw is BGRA, so raw.charCodeAt(i + 2) is the R byte (not “R from B”), and raw.charCodeAt(i + 0) is B (not “B from R”). Updating these comments will prevent confusion when maintaining the worker rendering path.

Suggested change
imgData.data[i + 0] = raw.charCodeAt(i + 2); // R from B
imgData.data[i + 1] = raw.charCodeAt(i + 1); // G
imgData.data[i + 2] = raw.charCodeAt(i + 0); // B from R
imgData.data[i + 3] = raw.charCodeAt(i + 3); // A
imgData.data[i + 0] = raw.charCodeAt(i + 2); // R (from BGRA index 2)
imgData.data[i + 1] = raw.charCodeAt(i + 1); // G (from BGRA index 1)
imgData.data[i + 2] = raw.charCodeAt(i + 0); // B (from BGRA index 0)
imgData.data[i + 3] = raw.charCodeAt(i + 3); // A (from BGRA index 3)

Copilot uses AI. Check for mistakes.
Comment on lines +192 to +212
private static registerProfilerCommandHandler(_config: UnoConfig, dotnetRuntime: any): void {
self.addEventListener("message", (e: any) => {
const msg = e.data;
if (!msg || msg.type !== 'uno-profiler-command') {
return;
}

try {
switch (msg.command) {
case 'memory-snapshot':
WorkerBootstrapper.handleMemorySnapshot(msg.format || 'speedscope');
break;

case 'log-profiler-save':
WorkerBootstrapper.handleLogProfilerSave(dotnetRuntime);
break;

case 'aot-profiler-save':
WorkerBootstrapper.handleAotProfilerSave(dotnetRuntime);
break;

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerProfilerCommandHandler triggers handleLogProfilerSave(...) (async) without awaiting or attaching a .catch(...). If getAssemblyExports/FS access throws, this can surface as an unhandled promise rejection and the host will never receive a uno-profiler-error message. Make the message handler async and await the async handlers (or explicitly .catch and post uno-profiler-error).

Copilot uses AI. Check for mistakes.
Comment on lines +151 to +157
g.saveLogProfile = function () {
WorkerBootstrapper.handleLogProfilerSave(dotnetRuntime);
console.info('[WorkerProfiler] Log profiler data posted to host for download.');
};

g.saveAotProfile = function () {
WorkerBootstrapper.handleAotProfilerSave(dotnetRuntime);
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console helpers (saveLogProfile, saveAotProfile) invoke potentially-async work (handleLogProfilerSave is async today, and handleAotProfilerSave should be async as well) but don't await it, yet immediately log "... posted to host". This can produce misleading output and unhandled rejections. Consider making these helpers async and awaiting the underlying calls (or logging success only after the uno-profiler-data message is posted).

Suggested change
g.saveLogProfile = function () {
WorkerBootstrapper.handleLogProfilerSave(dotnetRuntime);
console.info('[WorkerProfiler] Log profiler data posted to host for download.');
};
g.saveAotProfile = function () {
WorkerBootstrapper.handleAotProfilerSave(dotnetRuntime);
g.saveLogProfile = async function () {
await WorkerBootstrapper.handleLogProfilerSave(dotnetRuntime);
console.info('[WorkerProfiler] Log profiler data posted to host for download.');
};
g.saveAotProfile = async function () {
await WorkerBootstrapper.handleAotProfilerSave(dotnetRuntime);

Copilot uses AI. Check for mistakes.
onConfigLoaded: (monoConfig: any) => {
WorkerBootstrapper.configLoaded(config, monoConfig);
},
onDotnetReady: () => { },
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleLogProfilerSave depends on dotnetRuntime.Module.FS, but the worker’s DotnetModuleConfig passed to dotnetModule.default(...) does not request any Emscripten exports (unlike Bootstrapper.asDotnetConfig(), which sets exports: ["IDBFS","FS", ...]). If FS isn’t exported by default, log-profiler save will always fail in workers. Consider adding an exports list (at least FS, and likely the same list as the main bootstrapper, including emcc_exported_runtime_methods).

Suggested change
onDotnetReady: () => { },
onDotnetReady: () => { },
exports: (globalThis as any).emcc_exported_runtime_methods
? ["FS", ...(globalThis as any).emcc_exported_runtime_methods]
: ["FS"],

Copilot uses AI. Check for mistakes.
Comment on lines +722 to +733
<MSBuild Projects="$(_UnoWorkerProjectFullPath)"
Targets="_UnoGetTargetFramework"
Properties="Configuration=$(Configuration)">
<Output TaskParameter="TargetOutputs" PropertyName="_UnoWorkerTargetFramework" />
</MSBuild>

<MSBuild Projects="$(_UnoWorkerProjectFullPath)"
Targets="Restore;Publish"
Properties="Configuration=$(Configuration);_UnoIsNestedWorkerPublish=true" />

<PropertyGroup>
<_UnoWorkerPublishWwwroot>$(_UnoWorkerProjectDir)/bin/$(Configuration)/$(_UnoWorkerTargetFramework)/publish/wwwroot/</_UnoWorkerPublishWwwroot>
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_UnoPublishWebWorkerFramework captures TargetOutputs from the MSBuild task into a property (_UnoWorkerTargetFramework). TargetOutputs is an item list, so assigning it directly to a property is brittle and may not yield the expected TFM string, which would break the computed worker publish path. Prefer outputting to an item (ItemName) and then setting the property from that item (or pass TargetFramework explicitly when publishing the worker).

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 20, 2026 12:09
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

1 similar comment
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 34 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • src/Uno.Wasm.Tests.WebWorker/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +220 to +233
try {
switch (msg.command) {
case 'memory-snapshot':
WorkerBootstrapper.handleMemorySnapshot(msg.format || 'speedscope');
break;

case 'log-profiler-save':
WorkerBootstrapper.handleLogProfilerSave(dotnetRuntime);
break;

case 'aot-profiler-save':
WorkerBootstrapper.handleAotProfilerSave(dotnetRuntime);
break;

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerProfilerCommandHandler invokes async handlers (handleLogProfilerSave is async today, and handleAotProfilerSave will need to be async) without awaiting them. Any thrown/rejected Promise will bypass the surrounding try/catch and can surface as an unhandled rejection in the worker. Consider making the message callback async and awaiting these calls (or explicitly .catch(...) inside each branch).

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +76
if (config.uno_dependencies && config.uno_dependencies.length > 0) {
const depBase = (self as any).location.href.substring(0, (self as any).location.href.lastIndexOf('/') + 1);
for (const dep of config.uno_dependencies) {
try {
await import(depBase + dep + '.js');
} catch (e) {
console.warn(`[WorkerBootstrapper] Failed to load dependency ${dep}: ${e}`);
}
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worker dependency loading appends '.js' unconditionally (import(depBase + dep + '.js')). uno_dependencies entries can already include a .js suffix (e.g., when generated with an absolute base path), which would produce *.js.js and fail to load. Normalize the dependency URL (only append .js when it’s missing, and consider handling absolute URLs vs relative module IDs).

Copilot uses AI. Check for mistakes.
Comment on lines +318 to +325
private static handleAotProfilerSave(dotnetRuntime: any): void {
try {
const getExports = dotnetRuntime.getAssemblyExports;
if (!getExports) {
throw 'getAssemblyExports not available';
}

const exports = getExports("Uno.Wasm.AotProfiler");
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleAotProfilerSave calls dotnetRuntime.getAssemblyExports(...) synchronously, but in this codebase getAssemblyExports is async (returns a Promise). This will make exports.Uno... undefined/incorrect and break AOT profile saving. Make this method async, await dotnetRuntime.getAssemblyExports("Uno.Wasm.AotProfiler"), and only call StopProfile() after the exports are resolved.

Suggested change
private static handleAotProfilerSave(dotnetRuntime: any): void {
try {
const getExports = dotnetRuntime.getAssemblyExports;
if (!getExports) {
throw 'getAssemblyExports not available';
}
const exports = getExports("Uno.Wasm.AotProfiler");
private static async handleAotProfilerSave(dotnetRuntime: any): Promise<void> {
try {
const getExports = dotnetRuntime.getAssemblyExports;
if (!getExports) {
throw 'getAssemblyExports not available';
}
const exports = await getExports("Uno.Wasm.AotProfiler");

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-river-0087b630f-1056.eastus2.1.azurestaticapps.net

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants