Skip to content

Remove browser TZDIR support and allow custom relinked data - #137381

Open
jkoritzinsky wants to merge 5 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/remove-browser-tzdir
Open

jkoritzinsky wants to merge 5 commits into
dotnet:mainfrom
jkoritzinsky:dev/jkoritzinsky/remove-browser-tzdir

Conversation

@jkoritzinsky

@jkoritzinsky jkoritzinsky commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

As part of our effort to reduce VFS usage that can't be linked away, remove support for TZDIR in browser app scenarios.

Browser apps should use embedded time zone data rather than consult TZDIR or the filesystem at runtime. Apps that need a different database can instead select it at native relinking time.

  • Compile out browser timezone filesystem paths while preserving WASI TZDIR behavior.
  • Add WasmCustomTimezoneDataDirectory for Mono and CoreCLR browser apps. It embeds a complete compiled TZif directory with zone.tab, enables relinking automatically, and rejects incompatible settings.
  • Track data changes for incremental relinking and document the replacement behavior.

Validation

  • ./build.cmd tasks -c Release and ./build.cmd -os browser -arch wasm -c Release -subset clr+libs+host+packs: passed.
  • Browser System.Runtime timezone tests: 1,202 passed, 17 skipped; trimmed startup regression passed and filesystem helper chain was absent.
  • Custom-data browser integration: Mono main scenario and five invalid configurations passed; CoreCLR 6/6 passed. Covered data edits, adding/removing zones, directory switching, and restoring stock data.
  • WASI startup tests passed with both custom TZDIR and embedded data.

Note

This pull request was prepared with GitHub Copilot.

Embed custom browser time zone data during native relinking while preserving WASI behavior.

Co-authored-by: Copilot App <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@jkotas jkotas added area-System.DateTime os-browser Browser variant of arch-wasm and removed area-Build-mono labels Nov 11, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-datetime
See info in area-owners.md if you want to be subscribed.

@lewing

lewing commented Nov 12, 2026

Copy link
Copy Markdown
Member

How does this interact with InvariantTimezone?

@jkoritzinsky

Copy link
Copy Markdown
Member Author

InvariantTimezone takes priority over this

Replace TARGET_BROWSER/TARGET_WASI #if blocks with a constant-folded UseEmbeddedTzDatabase property so ILLink trims the filesystem paths on browser while keeping a single code shape.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A literal backslash in the timezone output path on Linux/macOS places the generated header outside the compiler’s include directory, blocking custom-data relinking.

1 open issue
What changed in this PR

This PR makes browser time zone lookup rely on embedded data rather than TZDIR or runtime filesystem access. It adds build-time database replacement for Mono and CoreCLR browser apps while preserving WASI’s TZDIR support.

Changes:

  • Use embedded time zone data unconditionally in browser apps.
  • Add WasmCustomTimezoneDataDirectory, validation, packaging, and incremental native relinking.
  • Document replacement behavior and add browser/WASI startup and custom-data regression tests.
File Description
src/​tasks/​WasmAppBuilder/​GenerateWasmTimezoneData.cs Generates embedding configuration and tracks input files.
src/​mono/​wasm/​Wasm.Build.Tests/​InvariantTimezoneTests.cs Tests custom databases, rebuilds, restoration, and invalid settings.
src/​mono/​wasm/​testassets/​EntryPoints/​CustomTimezone.cs Reports zone lookup and enumeration results.
src/​mono/​wasm/​features.md Documents browser database replacement and restrictions.
src/​mono/​nuget/​Microsoft.NET.Runtime.WebAssembly.Sdk/​Microsoft.NET.Runtime.WebAssembly.Sdk.pkgproj Packages timezone targets and native sources.
src/​mono/​browser/​build/​BrowserWasmApp.Timezone.targets Validates settings and compiles custom timezone data.
src/​mono/​browser/​build/​BrowserWasmApp.targets Integrates custom data into Mono relinking.
src/​mono/​browser/​build/​BrowserWasmApp.CoreCLR.targets Integrates custom data into CoreCLR relinking.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​TimeZoneDirectory/​TimeZoneDirectoryTests.cs Tests browser and WASI startup behavior with TZDIR.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​TimeZoneDirectory/​System.Runtime.TimeZoneDirectory.Tests.csproj Configures isolated startup tests and environment variables.
src/​libraries/​System.Runtime/​tests/​System.Runtime.Tests/​System/​TimeZoneInfoTests.cs Tests browser lookup ignoring filesystem overrides.
src/​libraries/​System.Runtime/​System.Runtime.slnx Registers the startup test project.
src/​libraries/​System.Private.CoreLib/​src/​System/​TimeZoneInfo.Unix.NonAndroid.cs Uses embedded browser data while retaining WASI filesystem support.

Review effort: Balanced

@jkoritzinsky
jkoritzinsky marked this pull request as ready for review November 18, 2026 19:36
Comment thread src/mono/wasm/features.md Resolved
Comment thread eng/native.wasm.targets Resolved

This branch has not been deployed

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

Labels

area-System.DateTime os-browser Browser variant of arch-wasm

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants