-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[wasm][icu] ICU files sharding + custom icu data loading for WASM #80421
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
Merged
ilonatommy
merged 79 commits into
dotnet:main
from
ilonatommy:wasm-browser-basic-sharding
Feb 24, 2023
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
4860837
User can set `GlobalizationShard`.
ilonatommy 234ee73
Sample for sharding, might be transformed into a test.
ilonatommy 6790c0f
Option of custom shard file upload.
ilonatommy 8b293c5
Replaced sample with WBT.
ilonatommy da5c9bc
Remove unnecessary change.
ilonatommy 5e8b107
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy 5ad7252
Fixed invariantMode + full custom path + nit.
ilonatommy a30970e
Draft of documentation.
ilonatommy 147d604
Rename to reflect usage better.
ilonatommy 5d2aa14
Fix full path file loading to the Browser.
ilonatommy ca4c9fe
Fix.
ilonatommy ef0782c
Fixed WBT build errors.
ilonatommy 002cbc5
Docs: only one ICU file can be used.
ilonatommy 2354514
Fixed NodeJs: `navigator` is not defined.
ilonatommy e8b1af5
Paritial fix of sharding tests.
ilonatommy b3ff241
RuntimePack can differ for AOT and Release.
ilonatommy 348d4bf
Fix `ja-JP` culture not found in CheckDateTimeLocale.
ilonatommy ef2dc3c
Fixedculture not found in SatelliteAssemblyTests.
ilonatommy b1b2b52
Fixed culture not found in System.Runtime tests.
ilonatommy 5df3c9c
`icudt.dat` should not be loaded when <IcuFileName> empty + EFIGS con…
ilonatommy d55aeb3
Improved doc readability using @radical's suggestions.
ilonatommy d229736
Forgot to remove comments.
ilonatommy f06aba4
Missing change for 5df3c9ccc851c45fbdbc3acfd96162c3237973c1.
ilonatommy 2d2ef60
WBT: Applied review.
ilonatommy 983e62b
Applied @pavelsavara's suggestion.
ilonatommy b5a1308
Added `WasmIncludeFullIcuData` to work like Blazor.
ilonatommy 5127929
Another missing change for 5df3c9ccc851c45fbdbc3acfd96162c3237973c1.
ilonatommy e86f132
Missing change for b5a1308372ed00f1dea08dadd647e97dffe57e27.
ilonatommy 0d2b732
Fix debugger failures for real, previous flag was in the wrong place.
ilonatommy 87caebd
Fixed most libraries that require full ICU.
ilonatommy 3abed9f
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy 9d5f54c
WBT should load full icu only when invariant off.
ilonatommy 1884b53
Applied @radical's idea.
ilonatommy ea5785c
Missing change for the last commit.
ilonatommy 04e97e4
Build args should not be edited inside of `BuildProject()` + Identity…
ilonatommy 2d8ec10
One flag for all lib tests instead of multiple changes.
ilonatommy 12408bb
Revert comments for the prev commit.
ilonatommy cc9750e
Fix for trimming tests.
ilonatommy 821afdc
Rename + throwing when file not found.
ilonatommy 9abdb6c
Fixed NoopNativeRebuildTest WBT.
ilonatommy beaa6e0
Forgotten logging.
ilonatommy d332ed9
Tests with custom shard.
ilonatommy 930a295
Added more complex tests.
ilonatommy ca0e1b8
Should fix wasm tests on helix.
ilonatommy 48f146f
Fix WBT.
ilonatommy 2fab2ec
Merge branch 'main' into wasm-browser-basic-sharding.
ilonatommy 016af2e
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy fd07a3c
[wasm] Update eng/testing/scenarios/BuildWasmAppsJobsList.txt
radical 0969201
[wasm] fix testassets path
radical 9b1cd94
Merge remote-tracking branch 'origin/main' into wasm-browser-basic-sh…
radical 125ede2
Default mode for tests should be the same as default mode for templat…
ilonatommy 984716f
Checking preferred icu when assets are still not populated was incorr…
ilonatommy ad5791e
DataTimeFormat does not work well for browser + wrong condition.
ilonatommy 3c36db4
Removed empty space changes.
ilonatommy 98b17e6
WBT for automatic icu selection based on locale.
ilonatommy 8a39ff5
Moved the full icu flag from libs to lib tests.
ilonatommy f47d570
Flag in tests.wasm.targets should be enough for trimming tests.
ilonatommy 358ecd4
Debugger tests in default globalization mode unless CJK needed. Firef…
ilonatommy 90c5f4f
Removing forgotten comment.
ilonatommy 5188563
Fixed sharding wbt.
ilonatommy 988b037
This should not be commented out.
ilonatommy 92cced7
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy dde05ee
Sharding WBT do not make sense on v8 + fixed debugger tests on Linux …
ilonatommy 6935c7e
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy 6d6f3bb
Cleanup.
ilonatommy cbd3803
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy 63e5e60
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy b414f33
Fix test to have sense.
ilonatommy 38a692c
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy e66edb0
Fixed tests to reflect expected behavior after removing predefinedCul…
ilonatommy 60199cd
Fixed merge errors, removed redundant comment.
ilonatommy ca1bd11
Update docs, disable NodeJS in tests.
ilonatommy 30d7096
@radical's review part 1: embedded comments.
ilonatommy f7c8b20
Merge branch 'main' into wasm-browser-basic-sharding
ilonatommy 8a27d8e
Merge with main and fix strange CI behavior.
ilonatommy f0484db
Test clean-up by @radical.
ilonatommy a9a0167
Fix WASI to treat ICU like WASM.
ilonatommy 839bb77
Fix arg order in debugger + revert wasi sharding.
ilonatommy f080222
It's a list, not a prop.
ilonatommy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # WASM Globalization Icu | ||
|
|
||
| In WASM applications when [globalization invariant mode](globalization-invariant-mode.md) is switched off, internalization data file is loaded. There are four basic types of these files: | ||
| - `icudt.dat` - full data | ||
| - `icudt_EFIGS.dat` - data for locales: "en-*", "fr-FR", "es-ES", "it-IT", and "de-DE". | ||
| - `icudt_CJK.dat` - for locales: "en" "ja", "ko", and "zh". | ||
| - `icudt_no_CJK.dat` - all locales from `icudt.dat`, excluding "ja", "ko", and "zh". | ||
|
|
||
| ## Wasm Console, Wasm Browser | ||
|
|
||
| We can specify the file we want to load, e.g. `icudt_no_CJK.dat` by adding to .csproj: | ||
| ``` | ||
| <WasmIcuDataFileName>icudt_no_CJK.dat</WasmIcuDataFileName> | ||
| ``` | ||
| Only one value for `WasmIcuDataFileName` can be set. It can also be a custom file, created by the developer. To create a custom ICU file, see `Custom ICU` section below. If no `WasmIcuDataFileName` was specified, the application's culture will be checked and the corresponding file will be loaded, e.g. for `en-US` file `icudt_EFIGS.dat`, and for `zh-CN` - `icudt_CJK.dat`. | ||
|
|
||
| ## Custom ICU | ||
|
|
||
| The easiest way to build ICU is to open https://github.com/dotnet/icu/ it in [Codespaces](docs\workflow\Codespaces.md). See files in https://github.com/dotnet/icu/tree/dotnet/main/icu-filters, and read https://unicode-org.github.io/icu/userguide/icu_data/buildtool.html#locale-slicing. Build your own filter or edit the existing file. | ||
| We advise to edit the filters **only by adding/removing locales** from the `localeFilter/whitelist` to avoid removing important data. We recommend not to remove "en-US" locale from the localeFilter/whitelist because it is used as a fallback. Removing it for when | ||
| - `<PredefinedCulturesOnly>true</PredefinedCulturesOnly>`: results in `Encountered infinite recursion while looking for resource in System.Private.Corelib.` exception | ||
| - when predefined cultures only is not set: results in resolving data from ICU's `root.txt` files, e.g. `CultureInfo.DateTimeFormat.GetDayName(DateTime.Today.DayOfWeek)` will return an abbreviated form: `Mon` instead of `Monday`. | ||
| Removing specific feature data might result in an exception that starts with `[CultureData.IcuGetLocaleInfo(LocaleStringData)] Failed`. It means you removed data necessary to extract basic information about the locale. | ||
|
|
||
| In the file `eng/icu.mk`, you can choose what filters to build. Choose the platform: | ||
|
|
||
| ### Building for Browser: | ||
| * For prerequisites run `.devcontainer/postCreateCommand.sh` (it is run automatically on creation if using Codespaces) | ||
| * Building: | ||
| ``` | ||
| ./build.sh /p:TargetOS=Browser /p:TargetArchitecture=wasm /p:IcuTracing=true | ||
| ``` | ||
| Output is located in `artifacts/bin/icu-browser-wasm`. | ||
|
|
||
| ### Building for Mobiles: | ||
| * For prerequisites run: | ||
| ```bash | ||
| export ANDROID_NDK_ROOT=$PWD/artifacts/ndk/ | ||
| mkdir $ANDROID_NDK_ROOT | ||
| wget https://dl.google.com/android/repository/android-ndk-r25b-linux.zip | ||
| unzip android-ndk-r25b-linux.zip -d $ANDROID_NDK_ROOT | ||
| rm android-ndk-r25b-linux.zip | ||
| mv $ANDROID_NDK_ROOT/*/* $ANDROID_NDK_ROOT | ||
| rmdir $ANDROID_NDK_ROOT/android-ndk-r25b | ||
| ``` | ||
| * Building: | ||
| ```bash | ||
| ./build.sh /p:TargetOS=Android /p:TargetArchitecture=x64 /p:IcuTracing=true | ||
| ``` | ||
|
|
||
| Output from both builds will be located in subdirectories of `artifacts/bin`. Copy the generated `.dat` files to a suitable location and provide the full path to it in the `.csproj`, e.g.: | ||
| ```xml | ||
| <WasmIcuDataFileName>C:\Users\wasmUser\icuSources\customIcu.dat</WasmIcuDataFileName> | ||
| ``` | ||
|
|
||
| ## Blazor | ||
|
|
||
| In Blazor we are loading the file based on the applications's culture. | ||
| To force the full data to be loaded, add this to your `.csproj`: | ||
| ```xml | ||
| <BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData> | ||
| ``` | ||
| Custom files loading for Blazor is not possible. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.