Skip to content

Conversation

@pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Sep 2, 2020

Description

.NET runtime started shipping globalization data in shards. Loading the shard based on the browser culture reduces the WASM download size which is desirable.

Customer impact

Reduced download size

Risk

Medium. Apps that configure the culture in .NET would require opting out of this feature. We attempt to detect this case, and we have tests for it, but we haven't seen how it behaves in the wild.


This change defaults Blazor to load icu shards rather than the full icu data dropping the size to 2046.15 KB from the current 2220.16 KB (~160KB reduction in size).

One of the issues that is being investigated is that loading icu data needs to happen using ambient data before the runtime has been loaded and not the .NET specified culture. We use navigator.languages which is the same property that is used by Emscripten to set the default culture. In addition, I've added a JS API that will allow users to specify a culture as part of initializing Blazor WebAssembly. This may help in the niche cases where the culture is readily known but users do not want to pay the cost of loading the full icu data.

I did not want to rely on the new API for our tests until we were happy with it. At the same time configuring browsers to launch with a specific culture requires all other browser instances to be gone. So writing a test that exercises the non-EFIGS data is a bit challenging.

@pranavkm pranavkm requested review from a team and SteveSandersonMS as code owners September 2, 2020 01:04
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Sep 2, 2020
@pranavkm pranavkm requested a review from lewing September 2, 2020 01:04
},

beginHeapLock: function() {
beginHeapLock: function () {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about this - I formatted the file and it made a bunch of changes. Use the Hide whitespaces option to avoid seeing unnecessary changes.

Copy link
Member

Choose a reason for hiding this comment

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

No problem. Best not to fight the tools :) If this is how VS code wants to format it, let's do it like that!

// culture in client-side Blazor.
// This type is internal since localization currently does not work.
// Make it public onc https://github.com/dotnet/runtime/issues/38124 is resolved.
internal class WebAssemblyGlobalizationTest : GlobalizationTest<ToggleExecutionModeServerFixture<Program>>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops

{
// Arrange
// This verifies the non-CJK icu data set.
var culture = new CultureInfo("kn");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lewing \ @EgorBo I authored a few tests to verify that Blazor is loading icu resources correctly one for each of the 3 shards. I verified that we're loading the right shard (and there's another test that verifies this for the ru culture), but this one appears to be failing.

    Assert.Equal() Failure
               ↓ (pos 1)
    Expected: 2/9/2020 12:00:00 ಪೂರ್ವಾಹ್ನ
    Actual:   2020-09-02 00:00:00

Copy link
Member

Choose a reason for hiding this comment

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

@pranavkm to be clear: is kn not expected to work in non-CJK icudt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@EgorBo I would have expected it to work. This doesn't seem specific to the shards. Even if I load icudt.dat, there's a bunch of different cultures for which it looks like culture data is missing.

Copy link
Member

Choose a reason for hiding this comment

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

@pranavkm sorry for the delay, the fix is here dotnet/icu#34
I guess we need to backport it to 5.0rc2 ?

Copy link
Member

Choose a reason for hiding this comment

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

the bug affects the following locales: "bn", "et", "gu", "kn", "ml", "mr", "ms", "no", "ta", "te"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we need to backport it to 5.0rc2 ?

We could definitely try asking. The risk is fairly limited and we have the opportunity to get better user feedback..

@pranavkm pranavkm changed the base branch from release/5.0 to release/5.0-rc2 September 3, 2020 01:07
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Looks good!

Really great job on the E2E tests here. That must have been quite difficult.

@pranavkm
Copy link
Contributor Author

pranavkm commented Sep 9, 2020

@Pilchie, could you approve this for rc2?

@Pilchie
Copy link
Member

Pilchie commented Sep 9, 2020

Approved for .NET 5. RC2. Are there any customers we can get to try out nightly builds once this is an installer to get some early validation and help us feel more comfortable with these changes.

@Pilchie Pilchie added the Servicing-approved Shiproom has approved the issue label Sep 9, 2020
@pranavkm
Copy link
Contributor Author

pranavkm commented Sep 9, 2020

@Pilchie we're going to reach out some community members on out Gitter and ask them to try out nightlies once they become available.

@mkArtakMSFT mkArtakMSFT added this to the 5.0.0-rc2 milestone Sep 10, 2020
@mkArtakMSFT mkArtakMSFT merged commit 2228c98 into release/5.0-rc2 Sep 10, 2020
@mkArtakMSFT mkArtakMSFT deleted the prkrishn/sharding branch September 10, 2020 17:17
@pranavkm pranavkm mentioned this pull request Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants