-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Avoid pinning JSInterop code when unused #36036
Conversation
Doesn't seem to building: https://dev.azure.com/dnceng/public/_build/results?buildId=1334810&view=results |
@TanayParikh could I have you try the E2E tests run in Release with this change to verify they pass? I'm having some trouble running the e2e tests locally and I'm not sure if they run on the CI |
Sure thing.
They don't anymore. |
```
[xUnit.net 00:00:35.41] Microsoft.AspNetCore.Components.E2ETests: 22:09:24.049 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Failed Microsoft.AspNetCore.Components.E2ETest.Tests.InteropTest.CanInvokeDotNetMethods [1 ms]
Error Message:
OpenQA.Selenium.BrowserAssertFailedException : Xunit.Sdk.NotEmptyException: Assert.NotEmpty() Failure
at Xunit.Assert.NotEmpty(IEnumerable collection) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 325
at Microsoft.AspNetCore.E2ETesting.WaitAssert.<>c__DisplayClass15_0.b__0() in C:\aspnetcore\src\Shared\E2ETesting\WaitAssert.cs:line 70
at Microsoft.AspNetCore.E2ETesting.WaitAssert.<>c__DisplayClass18_0`1.b__0(IWebDriver _) in C:\aspnetcore\src\Shared\E2ETesting\WaitAssert.cs:line 101
Screen shot captured at 'C:\aspnetcore\src\Components\test\E2ETest\bin\screenshots\803bc58461c94494830f4cf15fe8b89e.png'
Encountered browser errors
[2021-09-02T05:09:02Z] [Severe] http://127.0.0.1:59204/subdir - Failed to load resource: the server responded with a status of 404 (Not Found)Page content:
---- Assert.NotEmpty() Failure
Select test:
Choose...
Add/remove child components
After-render interop component
Async event handlers
Auth cases
Cascading authentication state
bind cases
Cascading values
Component ref component
Concurrent rendering
Configuration
Content-editable
Counter
Counter using child component
Counter wrapped in parent
Culture Picker
data-* attribute rendering
Dispatching to sync context
Duplicate attributes
DynamicComponent rendering
Element focus component
Element ref component
Error throwing
Error boundary cases
Event bubbling
EventCallback
Event custom arguments
Event disabling
Event during batch rendering
Event preventDefault
External content package
Focus events
Input Focus
INotifyPropertyChanged validation
Simple validation
Simple validation using experimental validator
Typical validation
Typical validation using experimental validator
Input file
Input range
Inputs without EditForm
Navigate to submit
Globalization Bind Cases
Graceful Termination
Head Modification
Imports statement
ChildContent HTML Block
ChildContent HTML Encoded Block
ChildContent Mixed Block
Binary HttpClient tester
HttpClient cookies
HttpClient tester
Input events
Interop component
Interop on initialization
JavaScript root components
JSON serialization
Key cases
Key press event
Laggy typing
Limit counter component
Localized Text
Logical element insertion cases
Logging
Long running interop
Markup blocks
Mouse events
Moving checkboxes diff case
Multiple child content
Navigation failure
Parent component with child
Parent component that changes parameters on child
Protected browser storage usage
Protected browser storage injection
Razor Templates
Reconnection server-side blazor
Red text
Server reliability component
Render fragment renderer
Render attributes before ConnectedCallback
Reordering focus retention
NavigationManager Test
Router
Router with OnNavigate
Router with dynamic assembly
Router with additional assembly
Select with component options
SignalR client
StringComparison
SVG
SVG Focus component
Plain text
Toggle Event
Touch events
Virtualization
Virtualization data changes
Render on hot reload
Invoke interop! Invocations.NET to JS calls: passing .NET object by ref, receiving .NET object by refReturn values and exceptions thrown from .NETExceptions thrown from JavaScriptExceptionFromSyncMethodSyncExceptionFromAsyncMethodAsyncExceptionFromAsyncMethodJSObjectReferenceInvokeNonFunctionException
---- Assert.NotEmpty() Failure
Select test:
Choose...
Add/remove child components
After-render interop component
Async event handlers
Auth cases
Cascading authentication state
bind cases
Cascading values
Component ref component
Concurrent rendering
Configuration
Content-editable
Counter
Counter using child component
Counter wrapped in parent
Culture Picker
data-* attribute rendering
Dispatching to sync context
Duplicate attributes
DynamicComponent rendering
Element focus component
Element ref component
Error throwing
Error boundary cases
Event bubbling
EventCallback
Event custom arguments
Event disabling
Event during batch rendering
Event preventDefault
External content package
Focus events
Input Focus
INotifyPropertyChanged validation
Simple validation
Simple validation using experimental validator
Typical validation
Typical validation using experimental validator
Input file
Input range
Inputs without EditForm
Navigate to submit
Globalization Bind Cases
Graceful Termination
Head Modification
Imports statement
ChildContent HTML Block
ChildContent HTML Encoded Block
ChildContent Mixed Block
Binary HttpClient tester
HttpClient cookies
HttpClient tester
Input events
Interop component
Interop on initialization
JavaScript root components
JSON serialization
Key cases
Key press event
Laggy typing
Limit counter component
Localized Text
Logical element insertion cases
Logging
Long running interop
Markup blocks
Mouse events
Moving checkboxes diff case
Multiple child content
Navigation failure
Parent component with child
Parent component that changes parameters on child
Protected browser storage usage
Protected browser storage injection
Razor Templates
Reconnection server-side blazor
Red text
Server reliability component
Render fragment renderer
Render attributes before ConnectedCallback
Reordering focus retention
NavigationManager Test
Router
Router with OnNavigate
Router with dynamic assembly
Router with additional assembly
Select with component options
SignalR client
StringComparison
SVG
SVG Focus component
Plain text
Toggle Event
Touch events
Virtualization
Virtualization data changes
Render on hot reload
Invoke interop! Invocations.NET to JS calls: passing .NET object by ref, receiving .NET object by refReturn values and exceptions thrown from .NETExceptions thrown from JavaScriptExceptionFromSyncMethodSyncExceptionFromAsyncMethodAsyncExceptionFromAsyncMethodJSObjectReferenceInvokeNonFunctionException
---- Assert.NotEmpty() Failure Failed! - Failed: 3, Passed: 1, Skipped: 0, Total: 4, Duration: 39 s - Microsoft.AspNetCore.Components.E2ETests.dll (net6.0)
|
In our current usage, JSStreamReference and it's associated code gets pinned because the converter is registered by default in the JSRuntime rooting the code. By moving the declaration to the type using a JsonConverterAttribute, we're able to trim this code if it's not used by the application. Numbers from trimming WebAssembly/testassets/StandaloneApp: Size on disk before: Microsoft.JSInterop.dll.br 14.0 KB (14,371 bytes) Microsoft.AspNetCore.Components.WebAssembly.dll.br 16.7 KB (17,130 bytes) Size on disk after: Microsoft.JSInterop.dll.br 13.9 KB (14,327 bytes) Microsoft.AspNetCore.Components.WebAssembly.dll.br 15.7 KB (16,151 bytes) Fixes #35186
821ccbf
to
260695a
Compare
I spent a bit of time updating and unfortunately this doesn't work in the current state. JsonConverterAttribute work on exact types so the attribute on |
Looks good |
In our current usage, JSStreamReference and it's associated code gets pinned because the converter is registered by default
in the JSRuntime rooting the code. By moving the declaration to the type using a JsonConverterAttribute, we're able to trim this
code if it's not used by the application.
Numbers from trimming WebAssembly/testassets/StandaloneApp:
Size on disk before:
Microsoft.JSInterop.dll.br 14.0 KB (14,371 bytes)
Microsoft.AspNetCore.Components.WebAssembly.dll.br 16.7 KB (17,130 bytes)
Size on disk after:
Microsoft.JSInterop.dll.br 13.9 KB (14,327 bytes)
Microsoft.AspNetCore.Components.WebAssembly.dll.br 15.7 KB (16,151 bytes)
Fixes #35186